#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long q, n;
  cin >> q;
  while (q--) {
    cin >> n;
    if ((n + 1) / 2 == 1 || n == 1) {
      cout << n << endl;
    } else {
      long long temp = (n + 1) / 2;
      long long r = n - temp;
      cout << temp - r << endl;
    }
  }
  return 0;
}
