#include<bits/stdc++.h>
using namespace std;
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    string s;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> s;
        sort(s.begin(), s.end());
        int br = 1, x = s.size(), brn = 0;
        bool b = 1;
        for (int j = 0; j < x-1; j++) {
            if (s[j] == s[j+1]) {
                br++;
                continue;
            }
            if (br%2 == 1) {
                brn++;
            }
            br = 1;
        }
        if (br%2 == 1) {
            brn++;
        }
        if (brn > 1) {
            b = 0;
        }
        cout << b;
    }
    return 0;
}