#include #include #include using namespace std; unsigned long long dpa[2][2][2][2],dpb[2][2][2][2]; int main(){ int t; scanf("%d",&t); while(t--){ unsigned long long a,b,c,d; scanf("%I64d%I64d%I64d%I64d",&a,&b,&c,&d); memset(dpa,0,sizeof(dpa)); for(int i=0;i<64;i++){ memset(dpb,0,sizeof(dpb)); for(unsigned int ld=0;ld<2;ld++){ for(unsigned int lu=0;lu<2;lu++){ for(unsigned int rd=0;rd<2;rd++){ for(unsigned int ru=0;ru<2;ru++){ unsigned int aa=ld?0:a&1,bb=lu?1:b&1,cc=rd?0:c&1,dd=ru?1:d&1; for(unsigned int ac=aa;ac<=bb;ac++){ for(unsigned int bc=cc;bc<=dd;bc++){ dpb[ld][lu][rd][ru]=max(dpb[ld][lu][rd][ru], dpa[ld||ac!=(a&1)][lu||ac!=(b&1)][rd||bc!=(c&1)][ru||bc!=(d&1)]+(ac!=bc)*(1ll<>=1,b>>=1,c>>=1,d>>=1; memcpy(dpa,dpb,sizeof(dpb)); } printf("%I64d\n",dpa[0][0][0][0]); } return 0; }