#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t;
  cin >> t;
  while (t--) {
    long long a, b;
    cin >> a >> b;
    long long c = a ^ b;
    a = a & c;
    b = b & c;
    cout << a + b << "\n";
  }
  return 0;
}
