#pragma GCC optimize("Ofast") #include using namespace std; #define rep(Ii,Jj,Kk) for(int Ii=(Jj),Ii##_=(Kk);Ii<=Ii##_;Ii++) #define per(Ii,Jj,Kk) for(int Ii=(Jj),Ii##_=(Kk);Ii>=Ii##_;Ii--) typedef long long ll; typedef unsigned long long ull; typedef unsigned uint; typedef long double db; #define fir first #define sec second #define siz(Aa) ((int)(Aa).size()) #define all(Aa) (Aa).begin(),(Aa).end() #define ckmx(Aa,Bb) (Aa=max(Aa,Bb)) #define ckmn(Aa,Bb) (Aa=min(Aa,Bb)) template struct mod_int{ using Z=mod_int; static signed mo(signed x){return x<0?x+P:x;} signed x; signed val()const{return x;} mod_int():x(0){} templatemod_int(const T&x_):x(x_>=0&&x_(x_):mo(static_cast(x_%P))){} bool operator==(const Z&rhs)const{return x==rhs.x;} bool operator!=(const Z&rhs)const{return x!=rhs.x;} Z operator-()const{return Z(x?P-x:0);} Z pow(long long k)const{Z res=1,t=*this;while(k){if(k&1)res*=t;if(k>>=1)t*=t;}return res;} Z operator~()const{assert(x);return pow(P-2);} Z&operator++(){x=P&&(x-=P);return *this;} Z&operator-=(const Z&rhs){(x-=rhs.x)<0&&(x+=P);return *this;} Z&operator*=(const Z&rhs){x=1ULL*x*rhs.x%P;return *this;} Z&operator/=(const Z&rhs){return *this*=~rhs;} #define setO(o) friend Z operator o(const Z&lhs,const Z&rhs){Z res=lhs;return res o##=rhs;} setO(+)setO(-)setO(*)setO(/) #undef setO friend istream& operator>>(istream&is,Z&x){long long y;is>>y;x=Z(y);return is;} friend ostream& operator<<(ostream&os,const Z&x){return os<; const int N=4e5+10; Z fac[N],ivf[N]; Z bin(int x,int y){ return fac[x]*ivf[y]*ivf[x-y]; } void work(){ int a,b,c,d; cin>>a>>b>>c>>d; if(a!=b){ cout<<"0\n"; }else if(a==0){ if(d>0){ cout<<"0\n"; }else{ cout<<"1\n"; } }else{ cout<>T; while(T--)work(); return 0;} /* */