#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const int maxn = 2e5 + 7;
const long long mod = 1000000007;
long long read() {
  long long x = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') ch = getchar();
  while (ch >= '0' && ch <= '9')
    x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
  return x;
}
void out(long long x) {
  int stackk[40];
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  if (!x) {
    putchar('0');
    return;
  }
  int top = 0;
  while (x) stackk[++top] = x % 10, x /= 10;
  while (top) putchar(stackk[top--] + '0');
}
long long a[222], b[222], cnt, res;
int main() {
  int toto = read();
  while (toto--) {
    long long aa, bb;
    memset(a, 0, sizeof(a));
    memset(b, 0, sizeof(b));
    cin >> aa >> bb;
    res = 0, cnt = 0;
    while (aa > 0) {
      a[++cnt] = aa % 2;
      aa /= 2;
    }
    while (bb > 0) {
      b[++res] = bb % 2;
      bb /= 2;
    }
    long long ans = 0;
    for (int i = 1; i <= max(res, cnt); i++) {
      if (a[i] != b[i]) ans += pow(2, i - 1);
    }
    out(ans);
    cout << endl;
  }
  return 0;
}
