#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define xx first #define yy second #define pb push_back #define mp make_pair #define LL long long #define inf INT_MAX/3 #define mod 100000007ll #define PI acos(-1.0) #define linf (1ll<<60)-1 #define FOR(I,A,B) for(int I = (A); I < (B); ++I) #define REP(I,N) FOR(I,0,N) #define ALL(A) ((A).begin(), (A).end()) #define set0(ar) memset(ar,0,sizeof ar) #define vsort(v) sort(v.begin(),v.end()) #define setinf(ar) memset(ar,126,sizeof ar) //cout << fixed << setprecision(20) << p << endl; template inline T bigmod(T p,T e,T M){ LL ret = 1; for(; e > 0; e >>= 1){ if(e & 1) ret = (ret * p) % M; p = (p * p) % M; } return (T)ret; } template inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);} template inline T modinverse(T a,T M){return bigmod(a,M-2,M);} vector < pair < int, pair < int, int > > > vc[2][2][2][2]; LL dp[70][2][2][2][2], ar[70][2], br[70][2]; LL go(int c, int f1, int f2, int g1, int g2){ if(c < 0) return 0; LL &ret = dp[c][f1][f2][g1][g2]; if(ret != -1) return ret; ret = 0; REP(i, vc[f1][f2][ar[c][0]][ar[c][1]].size()){ REP(j, vc[g1][g2][br[c][0]][br[c][1]].size()){ LL v = 0; if(vc[f1][f2][ar[c][0]][ar[c][1]][i].xx ^ vc[g1][g2][br[c][0]][br[c][1]][j].xx) v = 1ll< k) continue; if(j == 0 && p < l) continue; if(i == 0 && p == k){ if(j == 0 && p == l) vc[i][j][k][l].pb(mp(p, mp(i, j))); else vc[i][j][k][l].pb(mp(p, mp(i, 1))); } else { if(j == 0 && p == l) vc[i][j][k][l].pb(mp(p, mp(1, j))); else vc[i][j][k][l].pb(mp(p, mp(1, 1))); } } } } } } int T; cin >> T; while(T--){ LL a, b, c, d; cin >> a >> b >> c >> d; REP(i, 60){ ar[i][0] = (b & (1ll< 0 ? 1 : 0; ar[i][1] = (a & (1ll< 0 ? 1 : 0; br[i][0] = (d & (1ll< 0 ? 1 : 0; br[i][1] = (c & (1ll< 0 ? 1 : 0; } memset(dp, -1, sizeof dp); cout << go(60, 0, 0, 0, 0) << endl; } }