#include<bits/stdc++.h>
using namespace std;
int main(){
    int n=0;
    cin>>n;
    vector<string>v(n);
    for(int i=0; i<n; i++){
        cin>>v[i];
        sort(v[i].begin(), v[i].end());
        bool b=1;
        int b2=0;
        for(int j=0; j<v[i].size();j++){
            int br=1;
            while(v[i][j]==v[i][j+1]&&j<v[i].size()){
                br++;
                j++;
            }
            if(br%2==1){
                b2++;
            }
            if((b2>1)||(br%2!=0&&v[i].size()%2==0)){
                cout<<"0";
                b=0;
                break;
            }
        }
        if(b==1){
            cout<<1;
        }
    }
    return 0;
}
