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: ##########################################################################
  #     Author : nesco   
  #     Created: Sat Dec 25 2021 11:17:02
  #     File   : C. Menorah
  ##########################################################################
  import sys,math,cmath,time,collections
  ##########################################################################
  ################# ---- THE ACTUAL CODE STARTS BELOW ---- #################
  def solve():
      n = inp()
      a = insr()
      b = insr()
  
      n1 = 0
      n2 = 0
      m1 = 0
      m2 = 0
      same = 0
      diff = 0
      ones = 0
      zero = 0
      onessame = 0
      zerosame = 0
  
      for i in range(n):
          # if a[i] == '1':
          #     n1 = n1 + 1
          # else:
          #     m1 = m1 + 1
          
          # if b[i] == '1':
          #     n2 = n2 + 1
          # else:
          #     m2 = m2 + 1
  
          if a[i] == b[i]:
              same = same + 1
  
              if a[i] == '1':
                  onessame = onessame + 1
              else:
                  zerosame = zerosame + 1
          else:
              diff = diff + 1
  
              if (a[i] == '1'):
                  ones = ones + 1
              else:
                  zero = zero + 1
  
      # result = 0
      # if not (n1 == n2 and m1 == m2 or n2 == m1 + 1 and m2 == n1 - 1):
      #     result = -1
  
      # if result != -1:
          if same%2 == 0:
              if ones == zero:
                  result = diff
              else:
                  result = -1
          else:
              if ones == zero and onessame == zerosame + 1:
                  result = min(diff,same)
              elif ones == zero and onessame != zerosame + 1:
                  result = diff
              elif ones != zero and onessame == zerosame + 1:
                  result = same
              else:
                  result = -1
  
      print(result)
  
  
  ################## ---- THE ACTUAL CODE ENDS ABOVE ---- ##################
  ##########################################################################
   
  def main():
      global tt
      t = inp()
      for tt in range(1,t + 1):
          solve()
   
  #---------------------- USER DEFINED INPUT FUNCTIONS --------------------#
  def inp():   # input integer
      return(int(input()))
  def inlt():  # input list of integers
      return(list(map(int,input().split())))
  def inls():  # input list of strings
      return(list(map(str,input().split())))
  def insr():  # input string
      return(input().strip())
  def invr():  # input array
      return(map(int,input().split()))
   
  #------------------ USER DEFINED PROGRAMMING FUNCTIONS ------------------#
  # set to list converter
  def convert(set):
      return list(set)
  
  # outputs unique values from list
  def unique(list):
      list_set = set(list)
      unique_list = convert(list_set)
      return unique_list
  
  def seive(n):
      a = [1]
      prime = [True for i in range(n+1)] 
      p = 2
      while (p * p <= n): 
          if (prime[p] == True): 
              for i in range(p ** 2,n + 1, p): 
                  prime[i] = False
          p = p + 1
      for p in range(2,n + 1): 
          if prime[p]: 
              a.append(p)
      return(a)
  
  def counter(a):
      q = [0] * max(a)
      for i in range(len(a)):
          q[a[i] - 1] = q[a[i] - 1] + 1
      return(q)
   
  def counter_elements(a):
      q = dict()
      for i in range(len(a)):
          if a[i] not in q:
              q[a[i]] = 0
          q[a[i]] = q[a[i]] + 1
      return(q)
   
  def string_counter(a):
      q = [0] * 26
      for i in range(len(a)):
          q[ord(a[i]) - 97] = q[ord(a[i]) - 97] + 1
      return(q)
   
  def factorial(n,m = 1000000007):
      q = 1
      for i in range(n):
          q = (q * (i + 1)) % m
      return(q)
   
  def factors(n):
      q = []
      for i in range(1,int(n ** 0.5) + 1):
          if n % i == 0: q.append(i); q.append(n // i)
      return(list(sorted(list(set(q)))))
   
  def prime_factors(n):
      q = []
      while n % 2 == 0: q.append(2); n = n // 2
      for i in range(3,int(n ** 0.5) + 1,2):
          while n % i == 0: q.append(i); n = n // i
      if n > 2: q.append(n)
      return(list(sorted(q)))
   
  def transpose(a):
      n,m = len(a),len(a[0])
      b = [[0] * n for i in range(m)]
      for i in range(m): 
          for j in range(n): 
              b[i][j] = a[j][i]
      return(b)
   
  def power_two(x):
      return (x and (not(x & (x - 1))))
   
  def ceil(a, b):
      return -(-a // b)
  #-----------------------------------------------------------------------#
      
  main()