#include <bits/stdc++.h>
using namespace std;
const int maxn = 100010, mod = 998244353;
inline int read() {
  int x = 0, f = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') f |= ch == '-', ch = getchar();
  while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
  return f ? -x : x;
}
int n, a[maxn], b[maxn], sum;
int main() {
  n = read();
  for (int i = (1); i <= (n); i++) sum ^= a[i] = read();
  a[++n] = sum;
  for (int i = (1); i <= (n - 1); i++) sum ^= b[i] = read();
  b[n] = sum;
  puts("-1");
}
