#include using namespace std; typedef signed long long ll; #undef _P #define _P(...) (void)printf(__VA_ARGS__) #define FOR(x,to) for(x=0;x<(to);x++) #define FORR(x,arr) for(auto& x:arr) #define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++) #define ALL(a) (a.begin()),(a.end()) #define ZERO(a) memset(a,0,sizeof(a)) #define MINUS(a) memset(a,0xff,sizeof(a)) //------------------------------------------------------- const int prime_max = 2200000; int NP,prime[300000],divp[prime_max]; void cprime() { for(int i=2;ii&&jN_) break; int x=how(N_,prime[i])-how(C_,prime[i])-how(N_-C_,prime[i]); while(x--) ret = ret*prime[i] % (1<<21); } return ret; } ll hcomb(int P_,int Q_) { return (P_==0&&Q_==0)?1:combi(P_+Q_-1,Q_);} ll combi2(int N_, int C_) { return num2[N_]==num2[C_]+num2[N_-C_]; } ll hcomb2(int P_,int Q_) { return (P_==0&&Q_==0)?1:combi2(P_+Q_-1,Q_);} void solve() { int i,j,k,l,r,x,y; string s; cprime(); FOR(i,(1<<21)+50000) { j=i; while(j) num2[i]+=j/2, j/=2; } cout<>T; FOR(i,T) { cin>>A>>B>>C; if(C%2==0) { _P("0\n"); continue; } auto k=hcomb(C,B); if(k%(1<<21)==0) { _P("0\n"); continue; } ll a=C*k % (1<<21); _P("%lld\n",(hcomb2(a,A)%2)); } } int main(int argc,char** argv){ string s;int i; if(argc==1) ios::sync_with_stdio(false); FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin); solve(); return 0; }