#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 7;
int T, n, m;
int main() {
  scanf("%d", &T);
  while (T--) {
    scanf("%d%d", &n, &m);
    int k = (n | m);
    printf("%d\n", (n ^ k) + (m ^ k));
  }
  return 0;
}
