#include <bits/stdc++.h>
using namespace std;
template <class T>
T Bitcnt(T a) {
  int sum = 0;
  while (a) {
    if (a & 1) sum++;
    a /= 2;
  }
  return sum;
}
template <class T>
T Max3(T a, T b, T c) {
  return max(a, max(b, c));
}
template <class T>
T Lcm(T a, T b) {
  T tmp = __gcd(a, b);
  return (a / tmp) * b;
}
template <class T>
T Pow(T a, T b) {
  T ans = 1;
  T base = a;
  while (b) {
    if (b & 1) ans = (ans * base);
    base = (base * base);
    b /= 2;
  }
  return ans;
}
long long Bigmod(long long a, long long b) {
  long long res = 1;
  long long pw = a % 1000000007LL;
  while (b > 0) {
    if (b & 1) res = (res * pw) % 1000000007LL;
    pw = (pw * pw) % 1000000007LL;
    b /= 2;
  }
  return res;
}
int a_x[] = {1, -1, 0, 0};
int a_y[] = {0, 0, 1, -1};
long long X, Y;
void extend_euclid(long long a, long long b) {
  if (b == 0) {
    X = 1;
    Y = 0;
    return;
  }
  extend_euclid(b, a % b);
  long long x, y;
  x = Y;
  y = X - (a / b) * Y;
  X = x;
  Y = y;
}
long long inverse_modulo(long long a, long long b) {
  extend_euclid(a, b);
  return (X + 1000000007LL) % 1000000007LL;
}
long long d[300000];
long long b[300000], c[300000];
long long b1[300000], c1[300000];
long long bit[31][300000];
long long kbit[50];
long long a[300000];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i <= n - 1; i++) scanf("%d", &b[i]);
  for (int i = 0; i <= n - 1; i++) scanf("%d", &c[i]);
  for (int i = 0; i < n; i++) d[i] = (b[i] + c[i]);
  long long sum = 0;
  for (int i = 0; i < n; i++) sum += d[i];
  sum /= (2 * n);
  for (int i = 0; i < n; i++) {
    a[i] = (d[i] - sum) / n;
  }
  for (int i = 0; i < n; i++) {
    if (a[i] < 0) {
      cout << -1;
      return 0;
    }
  }
  for (int i = 0; i < 31; i++)
    for (int j = 0; j < n; j++) {
      if (a[j] & (1 << i)) {
        bit[i][j] = 1;
      } else
        bit[i][j] = 0;
    }
  for (int i = 0; i < 31; i++)
    for (int j = 0; j < n; j++) {
      kbit[i] += bit[i][j];
    }
  for (int i = 0; i < 31; i++)
    for (int j = 0; j < n; j++) {
      int bbase = bit[i][j] ? kbit[i] : 0;
      int cbase = bit[i][j] ? n : kbit[i];
      b1[j] += (bbase << i);
      c1[j] += (cbase << i);
    }
  for (int i = 0; i < n; i++) {
    if (b[i] != b1[i] || c[i] != c1[i]) {
      cout << -1;
      return 0;
    }
  }
  for (int i = 0; i < n; i++) cout << a[i] << " ";
  return 0;
}

### Prompt

In Cpp, your task is to solve the following problem:

Anton goes to school, his favorite lessons are arraystudying. He usually solves all the tasks pretty fast, but this time the teacher gave him a complicated one: given two arrays b and c of length n, find array a, such that:

<image>

where a and b means bitwise AND, while a or b means bitwise OR.

Usually Anton is good in arraystudying, but this problem is too hard, so Anton asks you to help.

Input

The first line of the input contains a single integers n (1 ≤ n ≤ 200 000) — the size of arrays b and c.

The second line contains n integers bi (0 ≤ bi ≤ 109) — elements of the array b.

Third line contains n integers ci (0 ≤ ci ≤ 109) — elements of the array c.

Output

If there is no solution, print  - 1.

Otherwise, the only line of the output should contain n non-negative integers ai — elements of the array a. If there are multiple possible solutions, you may print any of them.

Examples

Input

4
6 8 4 4
16 22 10 10


Output

3 5 1 1 


Input

5
8 25 14 7 16
19 6 9 4 25


Output

-1

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
template <class T>
T Bitcnt(T a) {
  int sum = 0;
  while (a) {
    if (a & 1) sum++;
    a /= 2;
  }
  return sum;
}
template <class T>
T Max3(T a, T b, T c) {
  return max(a, max(b, c));
}
template <class T>
T Lcm(T a, T b) {
  T tmp = __gcd(a, b);
  return (a / tmp) * b;
}
template <class T>
T Pow(T a, T b) {
  T ans = 1;
  T base = a;
  while (b) {
    if (b & 1) ans = (ans * base);
    base = (base * base);
    b /= 2;
  }
  return ans;
}
long long Bigmod(long long a, long long b) {
  long long res = 1;
  long long pw = a % 1000000007LL;
  while (b > 0) {
    if (b & 1) res = (res * pw) % 1000000007LL;
    pw = (pw * pw) % 1000000007LL;
    b /= 2;
  }
  return res;
}
int a_x[] = {1, -1, 0, 0};
int a_y[] = {0, 0, 1, -1};
long long X, Y;
void extend_euclid(long long a, long long b) {
  if (b == 0) {
    X = 1;
    Y = 0;
    return;
  }
  extend_euclid(b, a % b);
  long long x, y;
  x = Y;
  y = X - (a / b) * Y;
  X = x;
  Y = y;
}
long long inverse_modulo(long long a, long long b) {
  extend_euclid(a, b);
  return (X + 1000000007LL) % 1000000007LL;
}
long long d[300000];
long long b[300000], c[300000];
long long b1[300000], c1[300000];
long long bit[31][300000];
long long kbit[50];
long long a[300000];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i <= n - 1; i++) scanf("%d", &b[i]);
  for (int i = 0; i <= n - 1; i++) scanf("%d", &c[i]);
  for (int i = 0; i < n; i++) d[i] = (b[i] + c[i]);
  long long sum = 0;
  for (int i = 0; i < n; i++) sum += d[i];
  sum /= (2 * n);
  for (int i = 0; i < n; i++) {
    a[i] = (d[i] - sum) / n;
  }
  for (int i = 0; i < n; i++) {
    if (a[i] < 0) {
      cout << -1;
      return 0;
    }
  }
  for (int i = 0; i < 31; i++)
    for (int j = 0; j < n; j++) {
      if (a[j] & (1 << i)) {
        bit[i][j] = 1;
      } else
        bit[i][j] = 0;
    }
  for (int i = 0; i < 31; i++)
    for (int j = 0; j < n; j++) {
      kbit[i] += bit[i][j];
    }
  for (int i = 0; i < 31; i++)
    for (int j = 0; j < n; j++) {
      int bbase = bit[i][j] ? kbit[i] : 0;
      int cbase = bit[i][j] ? n : kbit[i];
      b1[j] += (bbase << i);
      c1[j] += (cbase << i);
    }
  for (int i = 0; i < n; i++) {
    if (b[i] != b1[i] || c[i] != c1[i]) {
      cout << -1;
      return 0;
    }
  }
  for (int i = 0; i < n; i++) cout << a[i] << " ";
  return 0;
}

```