B.cpp: In function 'bool sim(int, int)':
B.cpp:8:52: warning: suggest parentheses around '+' in operand of '&' [-Wparentheses]
for(int j=0; j<c; j++) for(int i=1; i<=N; i++) A[j+1&1][i] = (A[j&1][i-1] ^ A[j&1][i+1]);
~^~
B.cpp:10:34: warning: suggest parentheses around '-' in operand of '&' [-Wparentheses]
for(int i=1; i<=N; i++) f |= A[c-1&1][i];
~^~
B.cpp: In function 'int main()':
B.cpp:15:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
int T; scanf("%d",&T);
~~~~~^~~~~~~~~
B.cpp:17:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf(" %s", S+1);
~~~~~^~~~~~~~~~~~