description: There are n candles on a Hanukkah menorah, and some of its candles are initially lit. We can describe which candles are lit with a binary string s, where the i-th candle is lit if and only if s_i=1.
  
  <image>
  
  Initially, the candle lights are described by a string a. In an operation, you select a candle that is currently lit. By doing so, the candle you selected will remain lit, and every other candle will change (if it was lit, it will become unlit and if it was unlit, it will become lit).
  
  You would like to make the candles look the same as string b. Your task is to determine if it is possible, and if it is, find the minimum number of operations required.
  
  Input
  
  The first line contains an integer t (1≤ t≤ 10^4) — the number of test cases. Then t cases follow.
  
  The first line of each test case contains a single integer n (1≤ n≤ 10^5) — the number of candles.
  
  The second line contains a string a of length n consisting of symbols 0 and 1 — the initial pattern of lights.
  
  The third line contains a string b of length n consisting of symbols 0 and 1 — the desired pattern of lights.
  
  It is guaranteed that the sum of n does not exceed 10^5.
  
  Output
  
  For each test case, output the minimum number of operations required to transform a to b, or -1 if it's impossible.
  
  Example
  
  Input
  
  
  5
  5
  11010
  11010
  2
  01
  11
  3
  000
  101
  9
  100010111
  101101100
  9
  001011011
  011010101
  
  
  Output
  
  
  0
  1
  -1
  3
  4
  
  Note
  
  In the first test case, the two strings are already equal, so we don't have to perform any operations.
  
  In the second test case, we can perform a single operation selecting the second candle to transform 01 into 11.
  
  In the third test case, it's impossible to perform any operations because there are no lit candles to select.
  
  In the fourth test case, we can perform the following operations to transform a into b: 
  
    1. Select the 7-th candle: 100010{\color{red}1}11→ 011101{\color{red} 1}00. 
    2. Select the 2-nd candle: 0{\color{red} 1}1101100→ 1{\color{red} 1}0010011. 
    3. Select the 1-st candle: {\color{red}1}10010011→ {\color{red}1}01101100. 
  
  
  
  In the fifth test case, we can perform the following operations to transform a into b: 
  
    1. Select the 6-th candle: 00101{\color{red}1}011→ 11010{\color{red}1}100 
    2. Select the 2-nd candle: 1{\color{red}1}0101100→ 0{\color{red}1}1010011 
    3. Select the 8-th candle: 0110100{\color{red}1}1→ 1001011{\color{red}1}0 
    4. Select the 7-th candle: 100101{\color{red}1}10→ 011010{\color{red}1}01 
solution: /**
   * check out my youtube channel sh0rkyboy
   * https://tinyurl.com/zdxe2y4z
   * I do screencasts, solutions, and other fun stuff in the future
   */
  
  import java.util.*;
  import java.io.*;
  import static java.lang.Math.min;
  import static java.lang.Math.abs;
  import static java.lang.Math.max;
  public class EdB {
  	static long[] mods = {1000000007, 998244353, 1000000009};
  	static long mod = mods[0];
  	public static MyScanner sc;
      public static PrintWriter out;
  	public static void main(String[] largewang) throws Exception{
  		// TODO Auto-generated method stub
   		sc = new MyScanner();
   		out = new PrintWriter(System.out);
   		int t = sc.nextInt();
   		while (t-->0) {
   			int n = sc.nextInt();
   			char[] a = sc.next().toCharArray();
   			char[] b = sc.next().toCharArray();
   			int counta = 0;
   			int countb = 0;
   			for (char j : a) {
   				if (j == '1')
   					counta++;
   			}
   			for (char j : b) {
   				if (j == '1')
   					countb++;
   			}
   			long ans = 0;
   			if (counta == countb && n-counta+1 == countb){
   				for (int j = 0;j<n;j++){
   					if (b[j] == '1' && a[j] == '0') {
   						ans += 2;
   					}
   				}
   				long tempans = 0;
   				int j=0;
   				for(j = 0;j<n;j++){
   					if (a[j] == '1' && b[j] == '1')
   						break;
   				}
   				for(int i = 0;i<n;i++){
   					if (i == j)
   						continue;
   					if (a[i] == '1')
   						a[i] = '0';
   					else
   						a[i] = '1';
   				}
   				tempans += 1;
   				for (j = 0;j<n;j++){
   					if (b[j] == '1' && a[j] == '0') {
   						tempans += 2;
   					}
   				}
   				ans = min(ans, tempans);
   			} else if (counta == countb) {
   				for (int j = 0;j<n;j++){
   					if (b[j] == '1' && a[j] == '0') {
   						ans += 2;
   					}
   				}
   			} else if (n-counta+1 == countb) {
   				int j=0;
   				for(j = 0;j<n;j++){
   					if (a[j] == '1' && b[j] == '1')
   						break;
   				}
   				for(int i = 0;i<n;i++){
   					if (i == j)
   						continue;
   					if (a[i] == '1')
   						a[i] = '0';
   					else
   						a[i] = '1';
   				}
   				ans += 1;
   				for (j = 0;j<n;j++){
   					if (b[j] == '1' && a[j] == '0') {
   						ans += 2;
   					}
   				}
   			} else {
   				ans = -1;
   			}
   			out.println(ans);
    		}
   		out.close();
   		
   	}
  	
  	public static void sort(int[] array){
  		ArrayList<Integer> copy = new ArrayList<>();
  		for (int i : array)
  			copy.add(i);
  		Collections.sort(copy);
  		for(int i = 0;i<array.length;i++)
  			array[i] = copy.get(i);
  	}
  	static String[] readArrayString(int n){
  		String[] array = new String[n];
  		for(int j =0 ;j<n;j++)
  			array[j] = sc.next();
  		return array;
  	}
  	static int[] readArrayInt(int n){
      	int[] array = new int[n];
      	for(int j = 0;j<n;j++)
      		array[j] = sc.nextInt();
      	return array;
      }
  	static int[] readArrayInt1(int n){
  		int[] array = new int[n+1];
  		for(int j = 1;j<=n;j++){
  			array[j] = sc.nextInt();
  		}
  		return array;
  	}
  	static long[] readArrayLong(int n){
  		long[] array = new long[n];
  		for(int j =0 ;j<n;j++)
  			array[j] = sc.nextLong();
  		return array;
  	}
  	static double[] readArrayDouble(int n){
  		double[] array = new double[n];
  		for(int j =0 ;j<n;j++)
  			array[j] = sc.nextDouble();
  		return array;
  	}
  	static int minIndex(int[] array){
  		int minValue = Integer.MAX_VALUE;
  		int minIndex = -1;
  		for(int j = 0;j<array.length;j++){
  			if (array[j] < minValue){
  				minValue = array[j];
  				minIndex = j;
  			}
  		}
  		return minIndex;
  	}
  	static int minIndex(long[] array){
  		long minValue = Long.MAX_VALUE;
  		int minIndex = -1;
  		for(int j = 0;j<array.length;j++){
  			if (array[j] < minValue){
  				minValue = array[j];
  				minIndex = j;
  			}
  		}
  		return minIndex;
  	}
  	static int minIndex(double[] array){
  		double minValue = Double.MAX_VALUE;
  		int minIndex = -1;
  		for(int j = 0;j<array.length;j++){
  			if (array[j] < minValue){
  				minValue = array[j];
  				minIndex = j;
  			}
  		}
  		return minIndex;
  	}
  	public static int power(long x, long y, long mod){
  		long ans = 1;
  		while(y>0){
  			if (y%2==1)
  				ans = (ans*x)%mod;
  			x = (x*x)%mod;
  			y/=2;
  		}
  		return (int)(ans);
  	}
  	static void verdict(boolean a){
          out.println(a ? "YES" : "NO");
      }
      public static class MyScanner {
          BufferedReader br;
          StringTokenizer st;
          public MyScanner() {
              br = new BufferedReader(new InputStreamReader(System.in));
          }
          String next() { 
              while (st == null || !st.hasMoreElements()) {
                  try {
                      st = new StringTokenizer(br.readLine());
                  } 
                  catch (IOException e) {
                      e.printStackTrace();
                  }
              }
              return st.nextToken();
          }
          int nextInt() {
              return Integer.parseInt(next());
          }
          long nextLong() {
              return Long.parseLong(next());
          }
          double nextDouble() {
              return Double.parseDouble(next());
          }
          String nextLine() {
              String str = "";
              try{
                  str = br.readLine();
              } 
              catch (IOException e) {
                  e.printStackTrace();
              }
              return str;
          }
          
      }	
  }
  
  //StringJoiner sj = new StringJoiner(" "); 
  //sj.add(strings)
  //sj.toString() gives string of those stuff w spaces or whatever that sequence is