/* **********************************************

  File Name: 4131.cpp

  Author: zhengdongjian@tju.edu.cn

  Created Time: Sun, Apr  2, 2017  5:09:15 PM

*********************************************** */
#include <bits/stdc++.h>
using namespace std;

int main() {
    int T, a, b;
    scanf(" %d", &T);
    while (T--) {
        scanf(" %d %d", &a, &b);
        printf("%d\n", (a & b) > (a ^ b) ? 1 : 0);
    }
    return 0;
}
