#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int a, b, ans = 0, i = 0;
    cin >> a >> b;
    while (a > 0 || b > 0) {
      int x = a % 2, y = b % 2;
      if (x != y) ans |= 1 << i;
      i++;
      a /= 2;
      b /= 2;
    }
    cout << ans << '\n';
  }
}
