#include <bits/stdc++.h>
using namespace std;
long long in() {
  char ch = getchar();
  int flag = 0;
  long long x = 0;
  while (ch < '0' || ch > '9') flag |= (ch == '-'), ch = getchar();
  while (ch >= '0' && ch <= '9') x = x * 10 + (ch - '0'), ch = getchar();
  return flag ? -x : x;
}
long long t, n, a, b, x[1000], y[1000];
int main() {
  t = in();
  while (t--) {
    a = in(), b = in();
    memset(x, 0, sizeof(x));
    memset(y, 0, sizeof(y));
    while (a) x[++x[0]] = a % 2, a /= 2;
    while (b) y[++y[0]] = b % 2, b /= 2;
    long long ans = 0;
    for (long long i = 1, k = 1; i <= max(x[0], y[0]); i++, k *= 2) {
      if (x[i] != y[i]) ans += k;
    }
    printf("%lld\n", ans);
  }
  return 0;
}
