output_description: Print the minimum cost required to turn the original sequence into b_{1},
  b_{2}, ..., b_{N}. If the task is impossible, output -1 instead.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N
      a_{1} a_{2} ... a_{N}
      b_{1} b_{2} ... b_{N}
attempt: n, *a = map(int, open(0).read().split())
  a, b = a[:n], a[n:]
  for a, b in zip(a, b):
      if a == b:
          continue
      if b > a:
          print(-1)
          exit()
      if a - b < b:
          print(-1)
          exit()
  1 / 0
  
problem_description: Statement
  
  Aoki is playing with a sequence of numbers a_{1}, a_{2}, ..., a_{N}. Every
  second, he performs the following operation :
  
    * Choose a positive integer k. For each element of the sequence v, Aoki may choose to replace v with its remainder when divided by k, or do nothing with v. The cost of this operation is 2^{k} (regardless of how many elements he changes).
  
  Aoki wants to turn the sequence into b_{1}, b_{2}, ..., b_{N} (the order of
  the elements is important). Determine if it is possible for Aoki to perform
  this task and if yes, find the minimum cost required.
samples: [{"input": "3\n    19 10 14\n    0 3 4", "output": "160\n    \n\nHere's a possible sequence of operations :\n\n  * Choose k = 7. Replace 19 with 5, 10 with 3 and do nothing to 14. The sequence is now 5, 3, 14.\n\n  * Choose k = 5. Replace 5 with 0, do nothing to 3 and replace 14 with 4. The sequence is now 0, 3, 4.\n\nThe total cost is 2^{7} + 2^{5} = 160.\n\n* * *"}, {"input": "3\n    19 15 14\n    0 0 0", "output": "2\n    \n\nAoki can just choose k = 1 and turn everything into 0. The cost is 2^{1} = 2.\n\n* * *"}, {"input": "2\n    8 13\n    5 13", "output": "-1\n    \n\nThe task is impossible because we can never turn 8 into 5 using the given\noperation.\n\n* * *"}, {"input": "4\n    2 0 1 8\n    2 0 1 8", "output": "0\n    \n\nAoki doesn't need to do anything here. The cost is 0.\n\n* * *"}, {"input": "1\n    50\n    13", "output": "137438953472\n    \n\nBeware of overflow issues."}]