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

public class c1615 implements Runnable{
    
    public static void main(String[] args) {
        try{
            new Thread(null, new c1615(), "process", 1<<26).start();
        }
        catch(Exception e){
            System.out.println(e);
        }
    }
    public void run() {
        FastReader scan = new FastReader();
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
//      try {
//            out = new PrintWriter("file.out");
//        } catch (FileNotFoundException e) {
//            // TODO Auto-generated catch block
//            e.printStackTrace();
//        }
        Task solver = new Task();
        int t = scan.nextInt();
        //int t = 1;
        for(int i = 1; i <= t; i++) solver.solve(i, scan, out);
        out.close();
    }

    static class Task {
        static final int oo = Integer.MAX_VALUE;
        static final long OO = Long.MAX_VALUE;

        public void solve(int testNumber, FastReader sc, PrintWriter out) {
            int N = sc.nextInt();
            String a = sc.nextLine();
            String b = sc.nextLine();
            
            int same = 0;
            int ones = 0;
            
            int diff = 0;
            int dOnes = 0;
            for(int i = 0; i < a.length(); i++) {
                if(a.charAt(i) == b.charAt(i)) {
                    same++;
                    if(a.charAt(i) == '1') {
                        ones++;
                    }
                } else {
                    diff++;
                    if(a.charAt(i) == '1') {
                        dOnes++;
                    }
                }
            }
            
            int min = Integer.MAX_VALUE;
            if(same % 2 == 1 && ones >= (same - ones)) {
                min = same;
            }
            if(diff % 2 == 0 && dOnes >= (diff - dOnes)) {
                min = Math.min(same, diff);
            }
            
            if(min == Integer.MAX_VALUE) {
                out.println(-1);
            } else {
                out.println(min);
            }
        }
    }
    
    static long modDivide(long a, long b, long MOD) {
        a %= MOD;
        return (binpow(b, MOD-2, MOD) * a) % MOD;
    }
    static long binpow(long a, long b, long m) {
        a %= m;
        long res = 1;
        while (b > 0) {
            if ((b & 1) == 1)
                res = res * a % m;
            a = a * a % m;
            b >>= 1;
        }
        return res;
    }
    static int[] reverse(int a[]) 
    { 
        int[] b = new int[a.length]; 
        for (int i = 0, j = a.length; i < a.length; i++, j--) { 
            b[j - 1] = a[i]; 
        } 
        
        return b;
    }
    static long[] reverse(long a[]) 
    { 
        long[] b = new long[a.length]; 
        for (int i = 0, j = a.length; i < a.length; i++, j--) { 
            b[j - 1] = a[i]; 
        } 
        
        return b;
    }
    static void sort(int[] x){
        shuffle(x);
        Arrays.sort(x);
    }
    static void sort(long[] x){
        shuffle(x);
        Arrays.sort(x);
    }
    static class tup implements Comparable<tup>, Comparator<tup>{
        int a, b;
        tup(int a,int b){
            this.a=a;
            this.b=b;
        }
        public tup() {
        }
        @Override
        public int compareTo(tup o){
            return Integer.compare(b,o.b);
        }
        @Override
        public int compare(tup o1, tup o2) {
            return Integer.compare(o1.b, o2.b);
        }
        
        @Override
        public int hashCode() {
            return Objects.hash(a, b);
        }
 
        @Override
        public boolean equals(Object obj) {
            if (this == obj)
                return true;
            if (obj == null)
                return false;
            if (getClass() != obj.getClass())
                return false;
            tup other = (tup) obj;
            return a==other.a && b==other.b;
        }
        
        @Override
        public String toString() {
            return a + " " + b;
        }
    }
    
    static void shuffle(int[] a) {
        Random get = new Random();
        for (int i = 0; i < a.length; i++) {
            int r = get.nextInt(a.length);
            int temp = a[i];
            a[i] = a[r];
            a[r] = temp;
        }
    }

    static void shuffle(long[] a) {
        Random get = new Random();
        for (int i = 0; i < a.length; i++) {
            int r = get.nextInt(a.length);
            long temp = a[i];
            a[i] = a[r];
            a[r] = temp;
        }
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public FastReader(String s) throws FileNotFoundException {
            br = new BufferedReader(new FileReader(new File(s)));
        }

        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;
        }
        
        int[] readArray(int size) {
            int[] a = new int[size];
            for(int i = 0; i < size; i++) {
                a[i] = nextInt();
            }
            return a;
        }
        
        long[] readLongArray(int size) {
            long[] a = new long[size];
            for(int i = 0; i < size; i++) {
                a[i] = nextLong();
            }
            return a;
        }
    }
    
    static void dbg(int[] arr) {
        System.out.println(Arrays.toString(arr));
    }
    static void dbg(long[] arr) {
        System.out.println(Arrays.toString(arr));
    }
    static void dbg(boolean[] arr) {
        System.out.println(Arrays.toString(arr));
    }

    static void dbg(Object... args) {
        for (Object arg : args)
            System.out.print(arg + " ");
        System.out.println();
    }
}