## GUPTA MECHANICAL

IN THIS WEBSITE I CAN TELL ALL ABOUT TECH. TIPS AND TRICKS APP REVIEWS AND UNBOXINGS ALSO TECH. NEWS .............

# [Solution] Mark and Lightbulbs Codeforces Solution

D. Mark and Lightbulbs
time limit per test
1.5 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output
Mark has just purchased a rack of $n$ lightbulbs. The state of the lightbulbs can be described with binary string $s={s}_{1}{s}_{2}\dots {s}_{n}$, where ${s}_{i}=\mathtt{\text{1}}$ means that the $i$-th lightbulb is turned on, while ${s}_{i}=\mathtt{\text{0}}$ means that the $i$-th lightbulb is turned off.
Unfortunately, the lightbulbs are
broken, and the only operation he can perform to change the state of the lightbulbs is the following:
• Select an index $i$ from $2,3,\dots ,n-1$ such that ${s}_{i-1}\ne {s}_{i+1}$.
• Toggle ${s}_{i}$. Namely, if ${s}_{i}$ is $\mathtt{\text{0}}$, set ${s}_{i}$ to $\mathtt{\text{1}}$ or vice versa.
Mark wants the state of the lightbulbs to be another binary string $t$. Help Mark determine the
Solution Click Below:-  👉
👇👇👇👇👇
minimum number of operations to do so.

The first line of the input contains a single integer $q$ ($1\le q\le {10}^{4}$) — the number of test cases.
The first line of each test case contains a single integer $n$ ($3\le n\le 2\cdot {10}^{5}$) — the number of lightbulbs.
The second line of each test case contains a binary string $s$ of length $n$ — the initial state of the lightbulbs.
The third line of each test case contains a binary string $t$ of length $n$ — the final state of the lightbulbs.
It is guaranteed that the sum of $n$ across all test cases does not exceed $2\cdot {10}^{5}$.
For each test case, print a line containing the minimum number of operations Mark needs to perform to transform $s$ to $t$. If there is no such sequence of operations, print $-1$.
Input
Output