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 
import java.util.*;
import java.io.*;

////***************************************************************************
 /* public class E_Gardener_and_Tree implements Runnable{

       public static void main(String[] args) throws Exception {
        new Thread(null, new E_Gardener_and_Tree(), "E_Gardener_and_Tree", 1<<28).start();
       }
    public void run(){
         WRITE YOUR CODE HERE!!!!
         JUST WRITE EVERYTHING HERE WHICH YOU WRITE IN MAIN!!!
       }

  }
*/
/////**************************************************************************


public class C_Menorah{
    public static void main(String[] args) {
        FastScanner s= new FastScanner();
        //PrintWriter out=new PrintWriter(System.out);
        //end of program
        //out.println(answer);
        //out.close();
        StringBuilder res = new StringBuilder();
        int t=s.nextInt();
        int p=0;
        
        while(p<t){
        int n=s.nextInt();
        String str1=s.nextToken();
        String str2=s.nextToken();
       
        if(str1.equals(str2)){
            res.append("0 \n");
        }
      
        else{
            long count1=0;
            long count0=0;
            for(int i=0;i<n;i++){
                char ch=str1.charAt(i);
                if(ch=='1'){
                    count1++;
                }
            }
            count0=n-count1;
            if(count1==0){
                res.append("-1 \n");
            }
            else{
                long nice1=0;
                long nice0=0;
                for(int i=0;i<n;i++){
                    char ch=str2.charAt(i);
                    if(ch=='1'){
                        nice1++;
                    }
                }
                nice0=(n-nice1);
                int check1=0;
                int check2=0;
                if((count1==nice1)&&(count0==nice0)){
                    check1=1;
                }
                long yo1=(1+count0);
                long yo0=(count1-1);
                if((yo1==nice1)&&(yo0==nice0)){
                    check2=1;
                }
                if(check1==0 && check2==0){
                    res.append("-1 \n");
                }
                else{
                    //System.out.println("here");
                    long correct=0;
                    long wrong=0;
                    long correct1=0;
                    long correct0=0;
                    long wrong1=0;
                    long wrong0=0;
                   
                    for(int i=0;i<n;i++){
                        char ch1=str1.charAt(i);
                        char ch2=str2.charAt(i);
                        if(ch1==ch2){
                            correct++;
                            if(ch1=='1'){
                                correct1++;
                            }
                            else{
                                correct0++;
                            }
                        }
                        else{
                            wrong++;
                            if(ch1=='1'){
                                wrong1++;
                            }
                            else{
                                wrong0++;
                            }
                        }
                    }
              long ans1=      solve(correct1,correct0,wrong1,wrong0,1);
              long ans2=      solve(correct1,correct0,wrong1,wrong0,0);
              long ans=Math.min(ans1,ans2);
              if(ans>=Integer.MAX_VALUE){
                  ans=-1;
              }
              res.append(ans+" \n");
                  
                    
                   
                }



            }

        }
        p++;
    }
    
    System.out.println(res);
    
    }
    private static long solve( long correct1, long correct0, long wrong1, long wrong0,long a) {
               long op1=Integer.MAX_VALUE;
               long op2=Integer.MAX_VALUE;
               if(wrong1==0 && wrong0==0){
                   return 0;
               }
               if(a==1){
               {
                   // using correct1
                   if(correct1>0){
                       long newcorrect1=1+wrong0;
                       long newcorrect0=wrong1;
                       long newwrong1=correct0;
                       long newwrong0=correct1-1;
                       op1=(1+solve(newcorrect1,newcorrect0,newwrong1,newwrong0,0));

                   }
               }
            }
            else{

               {
                   //using wrong1
                   {
                       if(wrong1>0){
                        long newcorrect1=wrong0;
                        long newcorrect0=wrong1-1;
                        long newwrong1=1+correct0;
                        long newwrong0=correct1;
                        op2=(1+solve(newcorrect1,newcorrect0,newwrong1,newwrong0,1));
                       }
                   }
               }
            }  
               long ans=Math.min(op1,op2);
               return ans;
    
    }
    static class FastScanner {
		BufferedReader br;
		StringTokenizer st;
 
		public FastScanner(String s) {
			try {
				br = new BufferedReader(new FileReader(s));
			} catch (FileNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
 
		public FastScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
 
		String nextToken() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}
 
		int nextInt() {
			return Integer.parseInt(nextToken());
		}
 
		long nextLong() {
			return Long.parseLong(nextToken());
		}
 
		double nextDouble() {
			return Double.parseDouble(nextToken());
		}
	}


    static long modpower(long x, long y, long p)
     {
      long res = 1; // Initialize result
   
      x = x % p; // Update x if it is more than or
      // equal to p
   
      if (x == 0)
        return 0; // In case x is divisible by p;
   
      while (y > 0)
      {
   
        // If y is odd, multiply x with result
        if ((y & 1) != 0)
          res = (res * x) % p;
   
        // y must be even now
        y = y >> 1; // y = y/2
        x = (x * x) % p;
      }
      return res;
    }

  
   // SIMPLE POWER FUNCTION=>


      static long power(long x, long y)
        {
            long res = 1;     // Initialize result
        
            while (y > 0)
            {
            
                // If y is odd, multiply x with result
                if ((y & 1) != 0)
                    res = res * x;
        
                // y must be even now
                y = y >> 1; // y = y/2
                x = x * x;  // Change x to x^2
            }
            return res;
        }





}