#include <iostream>
#include <cstring>
#include <fstream>
using namespace std;
ifstream f("palindrom.in");
ofstream g("palindrom.out");
char s[202], w[200], ch, *cuv;
short n, i, m, pal;
int main()
{
f >> n;
f.get();
for (i=1; i<=n; ++i)
{
f.getline(s, 202);
m=strlen(s);
w[0]='\0';
cuv=strtok(s, " ");
while(cuv)
{
strcat(w,cuv);
cuv=strtok(NULL, " ");
}
m=strlen(w);
pal=1;
for(int j=0; j<m/2; ++j )
if (w[j]!=w[m-1-j]) {pal=0; break;}
if (pal) g << 1 << "\n";
else g << 0 << "\n";
}
}