#include<bits/stdc++.h>
using namespace std;
vector<string>v(1000);
bool run(string& a){
    long long br=0,f=0;
    for (long long i=0;i<a.size();i++){
        if (a[i]==' '){
            continue;
        }
        for (long long j=0;j<a.size();j++){
            ///if (j==i) continue;
            if (a[i]==a[j]){
                br++;
                a[j]==' ';
            }
        }
        if (br%2!=0){
            f++;
        }
        if (f>1)return false;
        br=0;
    }
    return true;
}
int main (){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long long n;
    cin >> n;
    string a;
    for (long long i=0;i<n;i++){
        cin >> v[i];
    }
    for (long long i=0;i<n;i++){
        cout << run(v[i]);
    }
    return 0;
}
