#include
using namespace std;
const int N = 2e6 + 10;
int a[N], b[N];
signed main() {
int T;
cin >> T;
while (T --) {
int n;
cin >> n;
for (int i = 1; i <= n; i ++)
cin >> a[i];
for (int i = 1; i <= n; i ++)
cin >> b[i];
int ans = 0;
for (int i = 30; ~i; i --) {
ans ^= (1 << i);
map <int, int> _1, _2;
for (int j = 1; j <= n; j ++)
_1[a[j] & ans] ++;
for (int j = 1; j <= n; j ++)
_2[b[j] & ans] ++;
for (int j = 1; j <= n; j ++)
if (_1[a[j] & ans] != _2[(a[j] & ans) ^ ans]) {
ans ^= (1 << i);
break;
}
}
cout << ans << '\n';
}
return 0;
}
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36