#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a;
  cin >> n;
  int hasil[101] = {0};
  for (int i = 1; i <= n; i++) {
    cin >> a;
    if (a / 2 != 1) {
      while (a % 2 != 0) {
        a++;
        hasil[i]++;
      }
    } else {
      a++;
      hasil[i]++;
      while (a % 2 != 0) {
        a++;
        hasil[i]++;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    cout << hasil[i] << endl;
  }
}
