/*
 * zyrch - Rupanshu Yadav
 */
#ifdef CREED
#include "creed.h"
#else
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <fstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <utility>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <cassert>
#include <sstream>
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#endif

using namespace std;

typedef long long ll;
typedef long double ld;
typedef double db;
typedef string str;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

#define forn(i,a,b) for (int i = (a); i < ll(b); ++i)
#define fo(i,a) forn(i,0,ll(a))
#define rforn(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define ro(i,a) rforn(i,0,a)
#define trav(a,x) for (auto& a: x)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define rsz resize
#define ins insert

#define mp make_pair
#define pb push_back
#define eb emplace_back
#define f first
#define s second

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef CREED
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

const ll INF = 9e18;

ll mod = 1000000007;
inline ll fast_expo(ll base,ll power,ll modulo=mod){
    base%=modulo;
    if (base<0) base+=modulo;
    ll x=base,cnt=power,ans=1;
    while(cnt){
        if (cnt&1) ans=(ans*x)%modulo;
        x=(x*x)%modulo;
        cnt>>=1;
    }
    return ans;
}

ll takemod(ll a, ll mo){
    a %= mo;
    if(a < 0) a+=mo;
    return a;
}

// if mod is prime
ll modinv(ll a, ll mo){
    return takemod(fast_expo(takemod(a,mo), mo-2, mo), mo);
}
// 297586BQ
//=========================CODE STARTS HERE=============================//

int main() {
    fast_cin();

    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdin);
    ll t;
    cin >> t;
    while(t--) {
	ll n;
	cin >> n;

	if (n & 1) {
	    cout << 0;
	}else cout << 1;
	cout << '\n';
    }
    return 0;
}


/*
 * zyrch - Rupanshu Yadav
 */
#ifdef CREED
#include "creed.h"
#else
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <fstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <utility>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <cassert>
#include <sstream>
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#endif

using namespace std;

typedef long long ll;
typedef long double ld;
typedef double db;
typedef string str;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

#define forn(i,a,b) for (int i = (a); i < ll(b); ++i)
#define fo(i,a) forn(i,0,ll(a))
#define rforn(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define ro(i,a) rforn(i,0,a)
#define trav(a,x) for (auto& a: x)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define rsz resize
#define ins insert

#define mp make_pair
#define pb push_back
#define eb emplace_back
#define f first
#define s second

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef CREED
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

const ll INF = 9e18;

ll mod = 1000000007;
inline ll fast_expo(ll base,ll power,ll modulo=mod){
    base%=modulo;
    if (base<0) base+=modulo;
    ll x=base,cnt=power,ans=1;
    while(cnt){
        if (cnt&1) ans=(ans*x)%modulo;
        x=(x*x)%modulo;
        cnt>>=1;
    }
    return ans;
}

ll takemod(ll a, ll mo){
    a %= mo;
    if(a < 0) a+=mo;
    return a;
}

// if mod is prime
ll modinv(ll a, ll mo){
    return takemod(fast_expo(takemod(a,mo), mo-2, mo), mo);
}
// 297586BQ
//=========================CODE STARTS HERE=============================//

int main() {
    fast_cin();

    ll t;
    cin >> t;

    while(t--) {
	ll n;
	cin >> n;

	if (n & 1) {
	    cout << 0;
	}else cout << 1;
	cout << '\n';
    }
    return 0;
}


/*
 * zyrch - Rupanshu Yadav
 */
#ifdef CREED
#include "creed.h"
#else
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <fstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <utility>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <cassert>
#include <sstream>
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#endif

using namespace std;

typedef long long ll;
typedef long double ld;
typedef double db;
typedef string str;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

#define forn(i,a,b) for (int i = (a); i < ll(b); ++i)
#define fo(i,a) forn(i,0,ll(a))
#define rforn(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define ro(i,a) rforn(i,0,a)
#define trav(a,x) for (auto& a: x)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define rsz resize
#define ins insert

#define mp make_pair
#define pb push_back
#define eb emplace_back
#define f first
#define s second

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef CREED
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

const ll INF = 9e18;

ll mod = 1000000007;
inline ll fast_expo(ll base,ll power,ll modulo=mod){
    base%=modulo;
    if (base<0) base+=modulo;
    ll x=base,cnt=power,ans=1;
    while(cnt){
        if (cnt&1) ans=(ans*x)%modulo;
        x=(x*x)%modulo;
        cnt>>=1;
    }
    return ans;
}

ll takemod(ll a, ll mo){
    a %= mo;
    if(a < 0) a+=mo;
    return a;
}

// if mod is prime
ll modinv(ll a, ll mo){
    return takemod(fast_expo(takemod(a,mo), mo-2, mo), mo);
}
// 297586BQ
//=========================CODE STARTS HERE=============================//

int main() {
    fast_cin();

    ll t;
    cin >> t;

    while(t--) {
	ll n;
	cin >> n;

	if (n & 1) {
	    cout << 0;
	}else cout << 1;
    }

    return 0;
}


/*
 * zyrch - Rupanshu Yadav
 */
#ifdef CREED
#include "creed.h"
#else
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <fstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <utility>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <cassert>
#include <sstream>
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#endif

using namespace std;

typedef long long ll;
typedef long double ld;
typedef double db;
typedef string str;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

#define forn(i,a,b) for (int i = (a); i < ll(b); ++i)
#define fo(i,a) forn(i,0,ll(a))
#define rforn(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define ro(i,a) rforn(i,0,a)
#define trav(a,x) for (auto& a: x)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define rsz resize
#define ins insert

#define mp make_pair
#define pb push_back
#define eb emplace_back
#define f first
#define s second

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef CREED
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

const ll INF = 9e18;

ll mod = 1000000007;
inline ll fast_expo(ll base,ll power,ll modulo=mod){
    base%=modulo;
    if (base<0) base+=modulo;
    ll x=base,cnt=power,ans=1;
    while(cnt){
        if (cnt&1) ans=(ans*x)%modulo;
        x=(x*x)%modulo;
        cnt>>=1;
    }
    return ans;
}

ll takemod(ll a, ll mo){
    a %= mo;
    if(a < 0) a+=mo;
    return a;
}

// if mod is prime
ll modinv(ll a, ll mo){
    return takemod(fast_expo(takemod(a,mo), mo-2, mo), mo);
}
// 297586BQ
//=========================CODE STARTS HERE=============================//

int main() {
    fast_cin();

    ll t;
    cin >> t;

    while(t--) {
	ll n;
	cin >> n;

	if (n & 1) {
	    cout << 0;
	}else cout << 1;
	cout << '\n';
    }

    return 0;
}


/*
 * zyrch - Rupanshu Yadav
 */
#ifdef CREED
#include "creed.h"
#else
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <fstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <utility>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <cassert>
#include <sstream>
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#endif

using namespace std;

typedef long long ll;
typedef long double ld;
typedef double db;
typedef string str;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

#define forn(i,a,b) for (int i = (a); i < ll(b); ++i)
#define fo(i,a) forn(i,0,ll(a))
#define rforn(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define ro(i,a) rforn(i,0,a)
#define trav(a,x) for (auto& a: x)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define rsz resize
#define ins insert

#define mp make_pair
#define pb push_back
#define eb emplace_back
#define f first
#define s second

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef CREED
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

const ll INF = 9e18;

ll mod = 1000000007;
inline ll fast_expo(ll base,ll power,ll modulo=mod){
    base%=modulo;
    if (base<0) base+=modulo;
    ll x=base,cnt=power,ans=1;
    while(cnt){
        if (cnt&1) ans=(ans*x)%modulo;
        x=(x*x)%modulo;
        cnt>>=1;
    }
    return ans;
}

ll takemod(ll a, ll mo){
    a %= mo;
    if(a < 0) a+=mo;
    return a;
}

// if mod is prime
ll modinv(ll a, ll mo){
    return takemod(fast_expo(takemod(a,mo), mo-2, mo), mo);
}
// 297586BQ
//=========================CODE STARTS HERE=============================//

int main() {
    fast_cin();

    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    ll t;
    cin >> t;
    while(t--) {
	ll n;
	cin >> n;

	if (n & 1) {
	    cout << 0;
	}else cout << 1;
	cout << '\n';
    }
    return 0;
}


#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#include <bits/stdc++.h>
#define pb push_back
typedef long long ll;
using namespace std;
int inf = 1e9+5;
const double PI = 3.1415926535897932384626433832795;

int main(){
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t;
    cin >> t;
    for(;t > 0;t--){
        int n;
        cin >> n;
        if(n%2 == 0){
            cout << "1\n";
        }else cout << 0;
    }
    return 0;
}


#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#include <bits/stdc++.h>
#define pb push_back
typedef long long ll;
using namespace std;
int inf = 1e9+5;
const double PI = 3.1415926535897932384626433832795;

int main(){
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t;
    cin >> t;
    for(;t > 0;t--){
        int n;
        cin >> n;
        if(n%2 == 0){
            cout << "1\n";
        }else cout << "0\n";
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> VL;
typedef vector<pair<ll,ll>> VPI;
typedef pair<ll,ll> PLL ;
typedef map<ll,ll> MLL;
#define EPS 1e-9
#define pb push_back
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007

int main() {
    std::ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin>>t;
    while(t--){
        int n;
        cin>>n;
        if(n%2==0){
            cout<<"1\n";
        }
        else cout<<"0\n";

        //INPUT FOR VECTOR LENGTH N
        // FOR(i,0,n){
        //   ll temp;
        //   cin>>temp;
        //   v.pb(temp);
        // }
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> VL;
typedef vector<pair<ll,ll>> VPI;
typedef pair<ll,ll> PLL ;
typedef map<ll,ll> MLL;
#define EPS 1e-9
#define pb push_back
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007

int main() {
    std::ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin>>t;
    while(t--){
        int n;
        cin>>n;
        if(!(n&1)){
            cout<<"1\n";
        }
        else cout<<"0\n";

    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> VL;
typedef vector<pair<ll,ll>> VPI;
typedef pair<ll,ll> PLL ;
typedef map<ll,ll> MLL;
#define EPS 1e-9
#define pb push_back
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007

int main() {
    std::ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ifstream cin;
    ofstream fout;
    cin.open("input.txt");
    fout.open("output.txt");
    int t;
    cin>>t;
    while(t--){
        int n;
        cin>>n;
        if(!(n&1)){
            fout<<"1\n";
        }
        else fout<<"0\n";

    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> VL;
typedef vector<pair<ll,ll>> VPI;
typedef pair<ll,ll> PLL ;
typedef map<ll,ll> MLL;
#define EPS 1e-9
#define pb push_back
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007

int main() {
    std::ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin>>t;
    while(t--){
        int n;
        cin>>n;
        if(n%2==0){
            cout<<"1\n";
        }
        else cout<<"0\n";

    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> VL;
typedef vector<pair<ll,ll>> VPI;
typedef pair<ll,ll> PLL ;
typedef map<ll,ll> MLL;
#define EPS 1e-9
#define pb push_back
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007

int main() {
    std::ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin>>t;
    while(t--){
        int n;
        cin>>n;
        cout<<!(n&1)<<"\n";

        //INPUT FOR VECTOR LENGTH N
        // FOR(i,0,n){
        //   ll temp;
        //   cin>>temp;
        //   v.pb(temp);
        // }
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> VL;
typedef vector<pair<ll,ll>> VPI;
typedef pair<ll,ll> PLL ;
typedef map<ll,ll> MLL;
#define EPS 1e-9
#define pb push_back
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007

int main() {
    std::ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin>>t;
    while(t--){
        int n;
        cin>>n;
        cout<<1-(n%2)<<"\n";

        //INPUT FOR VECTOR LENGTH N
        // FOR(i,0,n){
        //   ll temp;
        //   cin>>temp;
        //   v.pb(temp);
        // }
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> VL;
typedef vector<pair<ll,ll>> VPI;
typedef pair<ll,ll> PLL ;
typedef map<ll,ll> MLL;
#define EPS 1e-9
#define pb push_back
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007

int main() {
    std::ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t;
    cin>>t;
    while(t--){
        int n;
        cin>>n;
        cout<<!(n&1)<<"\n";

        //INPUT FOR VECTOR LENGTH N
        // FOR(i,0,n){
        //   ll temp;
        //   cin>>temp;
        //   v.pb(temp);
        // }
    }
    return 0;
}


//xtwakioi! xtwddYnoi(双重含义)!
#include <bits/stdc++.h>
#define ri register
#define int long long
#define E (n+1)
#define mk make_pair
using namespace std; const int N=510;
inline int read()
{
    int s=0, w=1; ri char ch=getchar();
    while(ch<'0'||ch>'9') { if(ch=='-') w=-1; ch=getchar(); }
    while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch^48), ch=getchar();
    return s*w;
}
signed main()
{
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	for(ri int T=read();T;T--)
	{
		int x=read();
		printf("%lld\n",(int)(!(x&1ll)));
	}
	return 0;
}


//xtwakioi! xtwddYnoi(双重含义)!
#include <bits/stdc++.h>
#define ri register
#define int long long
#define E (n+1)
#define mk make_pair
using namespace std; const int N=510;
inline int read()
{
    int s=0, w=1; ri char ch=getchar();
    while(ch<'0'||ch>'9') { if(ch=='-') w=-1; ch=getchar(); }
    while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch^48), ch=getchar();
    return s*w;
}
signed main()
{
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	for(ri int T=read();T;T--)
	{
		int x=read();
		printf("%lld\n",(int)(x&1ll));
	}
	return 0;
}


//xtwakioi! xtwddYnoi(双重含义)!
#include <bits/stdc++.h>
#define ri register
#define int long long
#define E (n+1)
#define mk make_pair
using namespace std; const int N=510;
inline int read()
{
    int s=0, w=1; ri char ch=getchar();
    while(ch<'0'||ch>'9') { if(ch=='-') w=-1; ch=getchar(); }
    while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch^48), ch=getchar();
    return s*w;
}
signed main()
{
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	int x=read();
	printf("%lld\n",(int)(x&1ll));
	return 0;
}


///supercalifragilisticexpialidocious.
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define f first
#define s second
#define mp make_pair
#define seper(n) setprecision(n)
#define sz(s) (int)s.size()
#define all(v) v.begin(),v.end()
#define IOS ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
typedef long long ll;
typedef pair<int , int> pii;
typedef pair<int , string> pis;
typedef map<int , int> mii;
typedef map<string , int> msi;
int main()
{
    ifstream fin("input.txt");
	ofstream fout("output.txt");
    int T , n;
    fin >> T;
    for(int i = 0 ; i < T ; i ++)
    {
        fin >> n;
        if(n % 2)
            fout << 0 << endl , 0;
        else
            fout << 1 << endl , 0;
    }
    return 0;
}


///supercalifragilisticexpialidocious.
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define f first
#define s second
#define mp make_pair
#define seper(n) setprecision(n)
#define sz(s) (int)s.size()
#define all(v) v.begin(),v.end()
#define IOS ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
typedef long long ll;
typedef pair<int , int> pii;
typedef pair<int , string> pis;
typedef map<int , int> mii;
typedef map<string , int> msi;
int main()
{
    int T , n;
    cin >> T;
    for(int i = 0 ; i < T ; i ++)
    {
        cin >> n;
        if(n % 2)
            cout << 1 << endl , 0;
        else
            cout << 0 << endl , 0;
    }
    return 0;
}


///supercalifragilisticexpialidocious.
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define f first
#define s second
#define mp make_pair
#define seper(n) setprecision(n)
#define sz(s) (int)s.size()
#define all(v) v.begin(),v.end()
#define IOS ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
typedef long long ll;
typedef pair<int , int> pii;
typedef pair<int , string> pis;
typedef map<int , int> mii;
typedef map<string , int> msi;
int main()
{
    int T , n;
    cin >> T;
    for(int i = 0 ; i < T ; i ++)
    {
        cin >> n;
        if(n % 2)
            cout << 0 << endl , 0;
        else
            cout << 1 << endl , 0;
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL)
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define all(a) a.begin(), a.end()
#define SORT(a) sort(all(a))
#define rep(i,n) for(i = 0; i < n; ++i)
#define rep1(i,n) for(i = 1; i <= n; ++i)
#define repr(i,n) for(i = n - 1; i >= 0; --i)
#define REP(i,k,n) for(i = k; i < n; ++i)
#define REPR(i,k,n) for(i = k; i >= 0; --i)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
ll i, j;

ll n, m, q, ans = 0;

void solve(){
    vector<int> v;
    ifstream in;
    in.open("input.txt");
    if(in.is_open()){
        while(!in.eof()){
            in >> q;
            v.resize(q);
            rep(i, q)   in >> v[i];
        }
    }

    ofstream out;
    out.open("output.txt");
    if(out.is_open()){
        for(auto e : v){
            if(e % 2)   out << 0 << endl;
            else    out << 1 << endl;
        }
    }
}

int main(){
    fastio;
    //cin >> q; while(q--)    solve();
    solve();
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>
#define forr(i,a,b) for(int i = int(a); i < int(b); ++i)
#define forn(i,n) forr(i,0,n)
#define rforr(i,a,b) for(int i = int(a); i > int(b); --i)
#define rforn(i,n) rforr(i,n,0)

typedef unsigned long long ull;
typedef long long ll;

using namespace std;

int main(){
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int T, N;
	cin>>T;
	forn(t, T){
		cin>>N;
		cout<<(N+1)%2<<'\n';
	}
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>
#define forr(i,a,b) for(int i = int(a); i < int(b); ++i)
#define forn(i,n) forr(i,0,n)
#define rforr(i,a,b) for(int i = int(a); i > int(b); --i)
#define rforn(i,n) rforr(i,n,0)

typedef unsigned long long ull;
typedef long long ll;

using namespace std;

int main(){
	//~ freopen("input.in", "r", stdin);
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int T, N;
	cin>>T;
	forn(t, T){
		cin>>N;
		cout<<(N+1)%2<<'\n';
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
    ifstream cin("input.txt");
    ofstream cout("output.txt");
    int t;
    fin >> t;
    for(int i = 0; i < t; i ++){
        int n;
        fin >> n;
        if(n % 2 == 0){
            fout << 1 << endl;
        }else{
            fout << 0 << endl;
        }
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
    ifstream fin("input.txt");
    ofstream fout("output.txt");
    int t;
    fin >> t;
    for(int i = 0; i < t; i ++){
        int n;
        fin >> n;
        if(n % 2 == 0){
            fout << 1 << endl;
        }else{
            fout << 0 << endl;
        }
    }
    return 0;
}


//Submitted by Amol

#include<bits/stdc++.h>
typedef long long int lld;

#define pb                    push_back
#define gspeed                ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define test                  int t; cin >>t; while(t--)
#define yy                    cout <<"YES" <<endl
#define nn                    cout <<"NO" <<endl
#define lcm(a,b)              (a*b)/(__gcd(a,b))
#define endl                  "\n"

using namespace std;

int main() {gspeed;
//	{
         test
         {
             int n;
             cin >> n;
             if(n%2==0)
                cout << 1 << endl;
             else
                cout << 0 << endl;
         }

		return 0;
	}


//Submitted by Amol

#include<bits/stdc++.h>
typedef long long int lld;

#define pb                    push_back
#define gspeed                ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define test                  int t; cin >>t; while(t--)
#define yy                    cout <<"YES" <<endl
#define nn                    cout <<"NO" <<endl
#define lcm(a,b)              (a*b)/(__gcd(a,b))
#define endl                  "\n"

using namespace std;

int main() {gspeed;
//	{

        #ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif

         test
         {
             int n;
             cin >> n;
             if(n%2==0)
                cout << 1 << endl;
             else
                cout << 0 << endl;
         }

		return 0;
	}


//Submitted by Amol

#include<bits/stdc++.h>
typedef long long int lld;

#define pb                    push_back
#define gspeed                ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define test                  int t; cin >>t; while(t--)
#define yy                    cout <<"YES" <<endl
#define nn                    cout <<"NO" <<endl
#define lcm(a,b)              (a*b)/(__gcd(a,b))
#define endl                  "\n"

using namespace std;

int main() {gspeed;
//	{

            freopen("input.txt", "r", stdin);
            freopen("output.txt", "w", stdout);

         test
         {
             int n;
             cin >> n;
             if(n%2==0)
                cout << 1 << endl;
             else
                cout << 0 << endl;
         }

		return 0;
	}


#include <iostream>
#include <fstream>
#include <sstream>

int main(){

    std::ifstream inputFile; inputFile.open("input.txt");
    int T; inputFile >> T;
    FILE * outputFile = fopen("output.txt","w");
    while(T--){
        long n; inputFile >> n;
        fputs((n % 2) ? "0\n" : "1\n", outputFile);
    }

    inputFile.close();
    fclose(outputFile);

    return 0;
}


#include <bits/stdc++>
using namespace std;

int main(){
    int t;cin >> t;
    while(t--){
        int n;
        cin >> n;
        if(n%2){
            cout << "0" << '\n';
        }
        else{
            cout << "1" << '\n';
        }
    }
}


#include <bits/stdc++.h>
using namespace std;

int main(){
    int t;
    cin >> t;
    while(t--){
        int n;
        cin >> n;
        if(n%2)cout << "0" << '\n';
        else cout << "1" < '\n';
    }
}


#include <bits/stdc++.h>
using namespace std;

int main(){
    int t;
    cin >> t;
    while(t!=0){
        int n;
        cin >> n;
        if(n%2)cout << "0" << '\n';
        else cout << "1" << '\n';
    }
}


#include <bits/stdc++.h>
using namespace std;

int main(){
    int t;
    cin >> t;
    while(t--){
        int n;
        cin >> n;
        if(n%2)cout << "0" << '\n';
        else cout << "1" << '\n';
    }
}


#include <bits/stdc++.h>
using namespace std;

int main(){
    int t;
    cin >> t;
    while(t!=0){
        int n;
        cin >> n;
        if(n%2)cout << "0" << '\n';
        else cout << "1" << '\n';
        t--;
    }
}


#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define file_io freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define fast_io ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef string str;
const ll MAXN = (ll) 1e5 + 10;
const ll INF = (ll) 1e6 + 10;
vector <int> v;
vector <ll> vec;
ll n,m,last,q,ans,k,x;
str s,t;
int main(){
	file_io;
	fast_io;
	cin>>n;
	for (int i=0; i<n; i++){
		cin>>x;
		if (x%2==0)	v.pb(1);
		else	v.pb(0);
	}
	for (int i=0; i<n; i++){
		cout<<v[i]<<endl;
	}
	return 0;
}

/*

	while (ALIVE){
			eat();
			code();
			sleep();
			repeat();
		}

			TIME OVER EVERY THING	==>	TIME	>	DIAMOND;

*/


#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef string str;
const ll MAXN = (ll) 1e5 + 10;
const ll INF = (ll) 1e6 + 10;
vector <int> v;
vector <ll> vec;
ll n,m,last,q,ans,k,x;
str s,t;
int main(){
	cin>>n;
	for (int i=0; i<n; i++){
		cin>>x;
		if (x%2==0)	v.pb(1);
		else	v.pb(0);
	}
	for (int i=0; i<n; i++){
		cout<<v[i]<<endl;
	}
	return 0;
}

/*

	while (ALIVE){
			eat();
			code();
			sleep();
			repeat();
		}

			TIME OVER EVERY THING	==>	TIME	>	DIAMOND;

*/


#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef string str;
const ll MAXN = (ll) 1e5 + 10;
const ll INF = (ll) 1e6 + 10;
vector <bool> v;
vector <ll> vec;
ll n,m,last,q,ans,k,x;
str s,t;
int main(){
	cin>>n;
	for (int i=0; i<n; i++){
		cin>>x;
		if (x%2==0)	v.pb(1);
		else	v.pb(0);
	}
	for (int i=0; i<n; i++){
		cout<<v[i]<<endl;
	}
	return 0;
}

/*

	while (ALIVE){
			eat();
			code();
			sleep();
			repeat();
		}

			TIME OVER EVERY THING	==>	TIME	>	DIAMOND;

*/


#include <bits/stdc++.h>

using namespace std;

#define int long long int
#define w(t) int t; cin>>t; while(t--)
#define mod 1000000007
#define pb push_back

int32_t main()
{
	w(t)
	{
		int n;
		cin>>n;
		if(n%2!=0)
		cout<<"0"<<"\n";
		else cout<<"1"<<"\n";

	}
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define int long long int
#define w(t) int t; cin>>t; while(t--)
#define mod 1000000007
#define pb push_back

int32_t main()
{
#ifdef DEBUG
  freopen("std.in", "r", stdin);
  freopen("std.out", "w", stdout);
  #else
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  #endif
	int t;
	cin>>t;
	for(int i=0;i<t;i++)
	{
		int n;
		cin>>n;
		if(n%2!=0)
		cout<<"0"<<"\n";
		else cout<<"1"<<"\n";
		}

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define int long long int
#define w(t) int t; cin>>t; while(t--)
#define mod 1000000007
#define pb push_back

int32_t main()
{
	int t;
	cin>>t;
	for(int i=0;i<t;i++)
	{
		int n;
		cin>>n;
		if(n%2!=0)
		cout<<"0"<<"\n";
		else cout<<"1"<<"\n";
		}

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main () {
    ios_base::sync_with_stdio(false);

    int t;
    cin >> t;

    while(t--){
        int n;
        cin >> n;
        cout << 1-(n%2) << endl;
    }

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main () {
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);

    int t;
    cin >> t;

    for(int i=0; i<t; i++){
        int n;
        cin >> n;
        cout << 1-(n%2) << endl;
    }

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main () {
    ios_base::sync_with_stdio(false);

    int t;
    cin >> t;

    for(int i=0; i<t; i++){
        int n;
        cin >> n;
        cout << 1-(n%2) << endl;
    }

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main () {
    ios_base::sync_with_stdio(false);

    int t;
    cin >> t;

    while(t--){
        int n;
        cin >> n;
        if(n%2==0) cout << 1 << endl;
        else cout << 0 << endl;
    }

    return 0;
}


/******************************** In the name of GOD *****************************/
#include<bits/stdc++.h>
using namespace std;

typedef long long                   ll;
typedef pair<int,int>               pii;
typedef pair<ll,ll>                 pll;
typedef pair<string , string>       pss;

#define all(x)                      (x).begin(),(x).end()
#define Sort(x)                     sort(all((x)))
#define F                           first
#define S                           second
#define sep                         ' '
#define file_io                     freopen("in.txt" , "r+" , stdin) ; freopen("out.txt" , "w+" , stdout);
#define fast_io                     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define error(x)                    cerr << "$$$ " << x << '\n';
#define error2(x,y)                 cerr << "#F : " << x << "      #S : " << y << '\n';
#define pb                          push_back

const ll MX5 = 5*1e5+3;
const ll MX6 = 1*1e6+3;
const ll INF = 8e18;
const ll MOD = 1e9 + 7;
const ll MOD2= 998244353;

ll power(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * power(a * a % md, b / 2, md) % md : power(a * a % md, b / 2, md) % md));
}
ll bmm(ll a,ll b){
    return (a%b==0 ? b : bmm(b,a%b));
}

ll A[MX5];

int main(){
    //fast_io
    file_io
    ll q;
    cin >> q;
    while(q--){
        ll n;
        cin >> n;
        ll ans=0;
        if(n%2){
            ans+=(n/2)*n+n/2+1;
        }
        else{
            ans=n*n/2;
        }
        if(ans%2){
            cout << 0;
        }
        else{
            cout << 1;
        }
        cout << endl;
    }
    return 0;
}

/*!
NNNNNNNN        NNNNNNNN IIIIIIIIII MMMMMMMM               MMMMMMMM                AAA
N;;;;;;;N       N;;;;;;N I::::::::I M;;;;;;;M             M;;;;;;;M               A:::A
N;;;;;;;;N      N;;;;;;N I::::::::I M;;;;;;;;M           M;;;;;;;;M              A\N.N/A
N;;;;;;;;;N     N;;;;;;N II::::::II M;;;;;;;;;M         M;;;;;;;;;M             A:::::::A
N;;;;;;;;;;N    N;;;;;;N   I::::I   M;;;;;;;;;;M       M;;;;;;;;;;M            A:::::::::A
N;;;;;;;;;;;N   N;;;;;;N   I::::I   M;;;;;;;;;;;M     M;;;;;;;;;;;M           A:::::A:::::A
N;;;;;;;N;;;;N  N;;;;;;N   I::::I   M:::::::M;;;;M   M;;;;M;;;;;;;M          A:::::A A:::::A
N;;;;;;N N;;;;N N;;;;;;N   I::::I   M;;;;;;M M;;;;M M;;;;M M;;;;;;M         A:::::A   A:::::A
N;;;;;;N  N;;;;N;;;;;;;N   I::::I   M;;;;;;M  M;;;;M;;;;M  M;;;;;;M        A:::::A     A:::::A
N;;;;;;N   N;;;;;;;;;;;N   I::::I   M;;;;;;M   M\\N.N//M   M;;;;;;M       A:::::AAAAAAAAA:::::A
N;;;;;;N    N;;;;;;;;;;N   I::::I   M;;;;;;M    M;;;;;M    M;;;;;;M      A:::In GOD we trust:::A
N;;;;;;N     N;;;;;;;;;N   I::::I   M;;;;;;M     MMMMM     M;;;;;;M     A:::::AAAAAAAAAAAAA:::::A
N;;;;;;N      N;;;;;;;;N II::::::II M;;;;;;M               M;;;;;;M    A:::::A             A:::::A
N;;;;;;N       N;;;;;;;N I::::::::I M;;;;;;M               M;;;;;;M   A:::::A               A:::::A
N;;;;;;N        N;;;;;;N I::::::::I M;;;;;;M               M;;;;;;M  A:::::A                 A:::::A
NNNNNNNN         NNNNNNN IIIIIIIIII MMMMMMMM               MMMMMMMM AAAAAAA                   AAAAAAA
*/


/******************************** In the name of GOD *****************************/
#include<bits/stdc++.h>
using namespace std;

typedef long long                   ll;
typedef pair<int,int>               pii;
typedef pair<ll,ll>                 pll;
typedef pair<string , string>       pss;

#define all(x)                      (x).begin(),(x).end()
#define Sort(x)                     sort(all((x)))
#define F                           first
#define S                           second
#define sep                         ' '
#define file_io                     freopen("input.txt" , "r+" , stdin) ; freopen("output.txt" , "w+" , stdout);
#define fast_io                     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define error(x)                    cerr << "$$$ " << x << '\n';
#define error2(x,y)                 cerr << "#F : " << x << "      #S : " << y << '\n';
#define pb                          push_back

const ll MX5 = 5*1e5+3;
const ll MX6 = 1*1e6+3;
const ll INF = 8e18;
const ll MOD = 1e9 + 7;
const ll MOD2= 998244353;

ll power(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * power(a * a % md, b / 2, md) % md : power(a * a % md, b / 2, md) % md));
}
ll bmm(ll a,ll b){
    return (a%b==0 ? b : bmm(b,a%b));
}

ll A[MX5];

int main(){
    //fast_io
    file_io
    ll q;
    cin >> q;
    while(q--){
        ll n;
        cin >> n;
        ll ans=0;
        if(n%2){
            ans+=(n/2)*n+n/2+1;
        }
        else{
            ans=n*n/2;
        }
        if(ans%2){
            cout << 0;
        }
        else{
            cout << 1;
        }
        cout << endl;
    }
    return 0;
}

/*!
NNNNNNNN        NNNNNNNN IIIIIIIIII MMMMMMMM               MMMMMMMM                AAA
N;;;;;;;N       N;;;;;;N I::::::::I M;;;;;;;M             M;;;;;;;M               A:::A
N;;;;;;;;N      N;;;;;;N I::::::::I M;;;;;;;;M           M;;;;;;;;M              A\N.N/A
N;;;;;;;;;N     N;;;;;;N II::::::II M;;;;;;;;;M         M;;;;;;;;;M             A:::::::A
N;;;;;;;;;;N    N;;;;;;N   I::::I   M;;;;;;;;;;M       M;;;;;;;;;;M            A:::::::::A
N;;;;;;;;;;;N   N;;;;;;N   I::::I   M;;;;;;;;;;;M     M;;;;;;;;;;;M           A:::::A:::::A
N;;;;;;;N;;;;N  N;;;;;;N   I::::I   M:::::::M;;;;M   M;;;;M;;;;;;;M          A:::::A A:::::A
N;;;;;;N N;;;;N N;;;;;;N   I::::I   M;;;;;;M M;;;;M M;;;;M M;;;;;;M         A:::::A   A:::::A
N;;;;;;N  N;;;;N;;;;;;;N   I::::I   M;;;;;;M  M;;;;M;;;;M  M;;;;;;M        A:::::A     A:::::A
N;;;;;;N   N;;;;;;;;;;;N   I::::I   M;;;;;;M   M\\N.N//M   M;;;;;;M       A:::::AAAAAAAAA:::::A
N;;;;;;N    N;;;;;;;;;;N   I::::I   M;;;;;;M    M;;;;;M    M;;;;;;M      A:::In GOD we trust:::A
N;;;;;;N     N;;;;;;;;;N   I::::I   M;;;;;;M     MMMMM     M;;;;;;M     A:::::AAAAAAAAAAAAA:::::A
N;;;;;;N      N;;;;;;;;N II::::::II M;;;;;;M               M;;;;;;M    A:::::A             A:::::A
N;;;;;;N       N;;;;;;;N I::::::::I M;;;;;;M               M;;;;;;M   A:::::A               A:::::A
N;;;;;;N        N;;;;;;N I::::::::I M;;;;;;M               M;;;;;;M  A:::::A                 A:::::A
NNNNNNNN         NNNNNNN IIIIIIIIII MMMMMMMM               MMMMMMMM AAAAAAA                   AAAAAAA
*/


/******************************** In the name of GOD *****************************/
#include<bits/stdc++.h>
using namespace std;

typedef long long                   ll;
typedef pair<int,int>               pii;
typedef pair<ll,ll>                 pll;
typedef pair<string , string>       pss;

#define all(x)                      (x).begin(),(x).end()
#define Sort(x)                     sort(all((x)))
#define F                           first
#define S                           second
#define sep                         ' '
#define file_io                     freopen("in.txt" , "r+" , stdin) ; freopen("out.txt" , "w+" , stdout);
#define fast_io                     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define error(x)                    cerr << "$$$ " << x << '\n';
#define error2(x,y)                 cerr << "#F : " << x << "      #S : " << y << '\n';
#define pb                          push_back

const ll MX5 = 5*1e5+3;
const ll MX6 = 1*1e6+3;
const ll INF = 8e18;
const ll MOD = 1e9 + 7;
const ll MOD2= 998244353;

ll power(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * power(a * a % md, b / 2, md) % md : power(a * a % md, b / 2, md) % md));
}
ll bmm(ll a,ll b){
    return (a%b==0 ? b : bmm(b,a%b));
}

ll A[MX5];

int main(){
    fast_io
    file_io
    ll q;
    cin >> q;
    while(q--){
        ll n;
        cin >> n;
        ll ans=0;
        if(n%2){
            ans+=(n/2)*n+n/2+1;
        }
        else{
            ans=n*n/2;
        }
        if(ans%2){
            cout << 0;
        }
        else{
            cout << 1;
        }
        cout << endl;
    }
    return 0;
}

/*!
NNNNNNNN        NNNNNNNN IIIIIIIIII MMMMMMMM               MMMMMMMM                AAA
N;;;;;;;N       N;;;;;;N I::::::::I M;;;;;;;M             M;;;;;;;M               A:::A
N;;;;;;;;N      N;;;;;;N I::::::::I M;;;;;;;;M           M;;;;;;;;M              A\N.N/A
N;;;;;;;;;N     N;;;;;;N II::::::II M;;;;;;;;;M         M;;;;;;;;;M             A:::::::A
N;;;;;;;;;;N    N;;;;;;N   I::::I   M;;;;;;;;;;M       M;;;;;;;;;;M            A:::::::::A
N;;;;;;;;;;;N   N;;;;;;N   I::::I   M;;;;;;;;;;;M     M;;;;;;;;;;;M           A:::::A:::::A
N;;;;;;;N;;;;N  N;;;;;;N   I::::I   M:::::::M;;;;M   M;;;;M;;;;;;;M          A:::::A A:::::A
N;;;;;;N N;;;;N N;;;;;;N   I::::I   M;;;;;;M M;;;;M M;;;;M M;;;;;;M         A:::::A   A:::::A
N;;;;;;N  N;;;;N;;;;;;;N   I::::I   M;;;;;;M  M;;;;M;;;;M  M;;;;;;M        A:::::A     A:::::A
N;;;;;;N   N;;;;;;;;;;;N   I::::I   M;;;;;;M   M\\N.N//M   M;;;;;;M       A:::::AAAAAAAAA:::::A
N;;;;;;N    N;;;;;;;;;;N   I::::I   M;;;;;;M    M;;;;;M    M;;;;;;M      A:::In GOD we trust:::A
N;;;;;;N     N;;;;;;;;;N   I::::I   M;;;;;;M     MMMMM     M;;;;;;M     A:::::AAAAAAAAAAAAA:::::A
N;;;;;;N      N;;;;;;;;N II::::::II M;;;;;;M               M;;;;;;M    A:::::A             A:::::A
N;;;;;;N       N;;;;;;;N I::::::::I M;;;;;;M               M;;;;;;M   A:::::A               A:::::A
N;;;;;;N        N;;;;;;N I::::::::I M;;;;;;M               M;;;;;;M  A:::::A                 A:::::A
NNNNNNNN         NNNNNNN IIIIIIIIII MMMMMMMM               MMMMMMMM AAAAAAA                   AAAAAAA
*/


///A drunk man will find his way home, but a drunk bird may get lost forever...
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define f first
#define s second
#define int long long
using namespace std;
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	ifstream fin("input.txt");
	ofstream fout("output.txt");
	int t, x;
	fin >> t;
	while(t--){
	    fin >> x;
	    if(x % 2)
	        fout << "1" << endl;
	    else
	        fout << "0" << endl;
	}
    return 0;
}


///A drunk man will find his way home, but a drunk bird may get lost forever...
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define f first
#define s second
#define int long long
using namespace std;
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	ifstream fin("input.txt");
	ofstream fout("output.txt");
	int t, x;
	fin >> t;
	while(t--){
	    fin >> x;
	    if(x % 2)
	        fout << "0" << endl;
	    else
	        fout << "1" << endl;
	}
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef unsigned long long int uli;

int main() {
    freeopen("input.txt", "r", stdin);
    freeopen("output.txt", "w", stdout);
    int t, n;
    cin >> t;
    while (t--) {
        cin >> n;
        if (n%2 == 0) {
            cout << 1 << "\n";
        }
        else {
            cout << 0 << "\n";
        }
    }
}


#include <iostream>
#include <cmath>
using namespace std;

typedef unsigned long long int uli;

int main() {
    freeopen("input.txt", "r", stdin);
    freeopen("output.txt", "w", stdout);
    int t, n;
    cin >> t;
    while (t--) {
        cin >> n;
        if (n%2 == 0) {
            cout << 1 << "\n";
        }
        else {
            cout << 0 << "\n";
        }
    }
}


#include <iostream>
#include <cmath>
using namespace std;

typedef unsigned long long int uli;

int main() {
    int t, n;
    cin >> t;
    while (t--) {
        cin >> n;
        if (n%2 == 0) {
            cout << 1 << "\n";
        }
        else {
            cout << 0 << "\n";
        }
    }
}


#include <bits/stdc++.h>
using namespace std;

typedef unsigned long long int uli;

int main() {
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    int t, n;
    cin >> t;
    while (t--) {
        cin >> n;
        if (n%2 == 0) {
            cout << 1 << "\n";
        }
        else {
            cout << 0 << "\n";
        }
    }
}


#include <bits/stdc++.h>

using namespace std;

int main()
{
	ifstream fin("input.txt");
	ofstream fout("output.txt");
	int q;
	fin >> q;
	while (q --)
	{
		int a;
		fin >> a;
		if (a % 2)
			fout << 0 << endl;
		else
			fout << 1 << endl;
	}
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main()
{
	int q;
	cin >> q;
	while (q --)
	{
		int a;
		cin >> a;
		if (a % 2)
			cout << 0 << endl;
		else
			cout << 1 << endl;
	}
	return 0;
}


#include<iostream>
using namespace std;

int main()
{
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    int n,t;
    cin>>t;
    while(t--){
        cin>>n;
        if(n&1) cout<<"0\n";
        else cout<<"1\n";
    }
    return 0;
}


#include<iostream>
using namespace std;

int main()
{
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    int n,t;
    cin>>t;
    while(t--){
        cin>>n;
        if(n==1) cout<<"0\n";
        else if(n==2 || n==3) cout<<"1\n";
        else if((n*((n-1)/3+1))%2) cout<<"0\n";
        else cout<<"1\n";
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int t, n;

int main() {
    ifstream cin("input.txt");
    ofstream cout("output.txt");
    cin >> t;
    while (t--) {
	cin >> n;
	cout << !(n % 2) << '\n';
    }
}


#include <bits/stdc++.h>

using namespace std;

int t, n;

int main() {
    ifstream("input.txt");
    ofstream("output.txt");
    cin >> t;
    while (t--) {
	cin >> n;
	cout << !(n % 2) << '\n';
    }
}


#include <bits/stdc++.h>

using namespace std;

int t, n;

int main() {
    ifstream("in.txt");
    ofstream("out.txt");
    cin >> t;
    while (t--) {
	cin >> n;
	cout << !(n % 2) << '\n';
    }
}


                                                                               #include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll t;
    cin>>t;
    while(t-->0)
    {
    ll n;
    if(n%2==0)
    {
     cout<<"1"<<"\n";
    }
else
{
                             cout<<"0"<<"\n";
}

}
return 0;}


#include<iostream>
#include<stdio.h>
using namespace std;

int main()
{
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    int t;
    cin >> t;
    int tem;
    for(int q=0;q<t;q++){
        cin >> tem;
        if(tem%2==1) cout << 0 << endl;
        else cout << 1 << endl;
    }
    return 0;
}


                                                                               #include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll t;
    cin>>t;
    while(t--)
    {
    ll n;
    cin>>n;
    if(n%2==0)
    {
     cout<<"1"<<"\n";
    }
else
{
                             cout<<"0"<<"\n";
}

}
return 0;}


                                                                               #include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll t;
    cin>>t;
    while(t-->0)
    {
    ll n;
    cin>>n;
    if(n%2==0)
    {
     cout<<"1"<<"\n";
    }
else
{
                             cout<<"0"<<"\n";
}

}
return 0;}


#include<iostream>
#include<cmath>
#include<vector>
#include<deque>
#include<set>
#include<map>
#include<algorithm>

using namespace std;

#define endl                 '\n'
#define gap                  ' '
#define MAX                  LLONG_MAX
#define MIN                  LLONG_MIN
#define min3(a,b,c)          min(a, min(b, c))
#define max3(a,b,c)          max(a, max(b, c))
#define remax(a, b)          a = max(a, b)
#define remin(a, b)          a = min(a, b)
#define MOD                  1000000007
#define PI                   3.1415926535897932384626433832795
#define nps                  string::npos
#define int                  int64_t
#define double               long double
#define vi                   vector<int>
#define di                   deque<int>
#define si                   set<int>
#define vpii                 vector<pair<int,int>>
#define dpii                 deque<pair<int,int>>
#define pi                   pair<int,int>
#define pub                  push_back
#define puf                  push_front
#define pob                  pop_back
#define pof                  pop_front
#define eb                   emplace_back
#define mpr                  make_pair
#define mtp                  make_tuple
#define rep(i, s, n)         for(int i = s; i < n; ++i)
#define repe(i, s, n)        for(int i = s; i <= n; ++i)
#define repr(i, n, s)        for(int i = n; i >= s; --i)
#define read(a)              for(auto& xy : a) cin >> xy
#define speak(a)             for(auto& xy : a) cout << xy << ' ';cout<<endl
#define work(xy, a)          for(auto& xy : a)
#define sz(x)                (int)(x).size()
#define all(a)               (a).begin(),(a).end()
#define rall(a)              (a).rbegin(),(a).rend()
#define __pre(x,s)           ((x).find(s) != (x).end())
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);

int32_t main() {
    ios_base::sync_with_stdio (false);
    cin.tie (0);
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    int t;cin>>t;
    while(t--){
    	int n;
    	cin >> n;
    	cout<<(n%2 ==0?1:0)<<endl;
    }
}


#include<iostream>
#include<cmath>
#include<vector>
#include<deque>
#include<set>
#include<map>
#include<algorithm>

using namespace std;

#define endl                 '\n'
#define gap                  ' '
#define MAX                  LLONG_MAX
#define MIN                  LLONG_MIN
#define min3(a,b,c)          min(a, min(b, c))
#define max3(a,b,c)          max(a, max(b, c))
#define remax(a, b)          a = max(a, b)
#define remin(a, b)          a = min(a, b)
#define MOD                  1000000007
#define PI                   3.1415926535897932384626433832795
#define nps                  string::npos
#define int                  int64_t
#define double               long double
#define vi                   vector<int>
#define di                   deque<int>
#define si                   set<int>
#define vpii                 vector<pair<int,int>>
#define dpii                 deque<pair<int,int>>
#define pi                   pair<int,int>
#define pub                  push_back
#define puf                  push_front
#define pob                  pop_back
#define pof                  pop_front
#define eb                   emplace_back
#define mpr                  make_pair
#define mtp                  make_tuple
#define rep(i, s, n)         for(int i = s; i < n; ++i)
#define repe(i, s, n)        for(int i = s; i <= n; ++i)
#define repr(i, n, s)        for(int i = n; i >= s; --i)
#define read(a)              for(auto& xy : a) cin >> xy
#define speak(a)             for(auto& xy : a) cout << xy << ' ';cout<<endl
#define work(xy, a)          for(auto& xy : a)
#define sz(x)                (int)(x).size()
#define all(a)               (a).begin(),(a).end()
#define rall(a)              (a).rbegin(),(a).rend()
#define __pre(x,s)           ((x).find(s) != (x).end())
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);

int32_t main() {
    ios_base::sync_with_stdio (false);
    cin.tie (0);
    int t;cin>>t;
    while(t--){
    	int n;
    	cin >> n;
    	cout<<(n%2 ==0?1:0)<<endl;
    }
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define SaveTime ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define mx *max_element
#define mi *min_element
#define fn for(long long int i =0 ;i <n;i++)
#define fn1 for(long long int i =1;i<=n;i++)
#define fm for(long long int j =0 ;j <m;j++)
#define fm1 for(long long int j =1;j<=m;j++)
#define fi first
#define se second
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
const int N = 1e6+5;
const ll INF = 1e18L;
ll ar[N];
ll tree[2*N];
ll dp[N];
int main(){
	#ifndef ONLINE_JUDGE
	freopen("lele.txt","r",stdin);
	freopen("dede.txt","w",stdout);
	#endif
	SaveTime;
	ll t ;
	cin >> t;
	while(t--){
		ll n ;
		cin >> n ;
		if(n&1)cout<<"0\n";
		else
			cout<<"1\n";
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define SaveTime ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define mx *max_element
#define mi *min_element
#define fn for(long long int i =0 ;i <n;i++)
#define fn1 for(long long int i =1;i<=n;i++)
#define fm for(long long int j =0 ;j <m;j++)
#define fm1 for(long long int j =1;j<=m;j++)
#define fi first
#define se second
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
const int N = 1e6+5;
const ll INF = 1e18L;
ll ar[N];
ll tree[2*N];
ll dp[N];
int main(){
// 	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
// 	#endif
	SaveTime;
	ll t ;
	cin >> t;
	while(t--){
		ll n ;
		cin >> n ;
		if(n&1)cout<<"0\n";
		else
			cout<<"1\n";
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define SaveTime ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define mx *max_element
#define mi *min_element
#define fn for(long long int i =0 ;i <n;i++)
#define fn1 for(long long int i =1;i<=n;i++)
#define fm for(long long int j =0 ;j <m;j++)
#define fm1 for(long long int j =1;j<=m;j++)
#define fi first
#define se second
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
const int N = 1e6+5;
const ll INF = 1e18L;
ll ar[N];
ll tree[2*N];
ll dp[N];
int main(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	SaveTime;
	ll t ;
	cin >> t;
	while(t--){
		ll n ;
		cin >> n ;
		if(n&1)cout<<"0\n";
		else
			cout<<"1\n";
	}
	return 0;
}


#include<bits/stdc++.h>
#define int long long int
#define pb push_back
#define mod 1000000007
#define IOS ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL);
using namespace std;
signed main()
{
    ///IOS
    ///if input from files uncomment
    freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
    int n;
    cin>>n;
    if(n%2)
        cout<<0<<"\n";
    else
        cout<<1<<"\n";
    return 0;
}


#include<bits/stdc++.h>
#define int long long int
#define pb push_back
#define mod 1000000007
#define IOS ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL);
using namespace std;
signed main()
{
    ///IOS
    ///if input from files uncomment
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    int t;
    cin>>t;
    while(t--)
    {
        int n;
        cin>>n;
        if(n%2)
            cout<<0<<"\n";
        else
            cout<<1<<"\n";

    }
    return 0;
}


#include<bits/stdc++.h>
#define ll long long int
#define mk make_pair
#define pb push_back
#define INF (ll)1e18
#define pii pair<ll,ll>
#define mod 1000000007 //998244353
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fb(i,a,b) for(ll i=a;i>b;i--)
#define ff first
#define ss second
#define PI 3.141592653589793238
#define pq priority_queue<ll>
#define pqr priority_queue<ll,vector<ll>,greater<ll>()>
using namespace std;
ll pow_mod(ll a,ll b)
{
	ll res=1;
	while(b!=0)
	{
		if(b&1)
		{
			res=(res*a)%mod;
		}
		a=(a*a)%mod;
		b/=2;
	}
	return res;
}
void solve()
{
  ll n;  // n is the size of chessboard
  cin>>n;

  ll ans=0;

  ll res=(n+2)/3;
  res*=n;

  if(res%2==0)
  ans=1;

  cout<<ans<<endl;
}
int32_t main()
{    ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     cout.tie(NULL);

//Start from Here.
 freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
  ll t;
  t=1;
  cin>>t;
  while(t--)
  solve();

//Good Bye!
    return 0;
}


#include<bits/stdc++.h>
#define ll long long int
#define mk make_pair
#define pb push_back
#define INF (ll)1e18
#define pii pair<ll,ll>
#define mod 1000000007 //998244353
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fb(i,a,b) for(ll i=a;i>b;i--)
#define ff first
#define ss second
#define PI 3.141592653589793238
#define pq priority_queue<ll>
#define pqr priority_queue<ll,vector<ll>,greater<ll>()>
using namespace std;
ll pow_mod(ll a,ll b)
{
	ll res=1;
	while(b!=0)
	{
		if(b&1)
		{
			res=(res*a)%mod;
		}
		a=(a*a)%mod;
		b/=2;
	}
	return res;
}
void solve()
{
  ll n;  // n is the size of chessboard
  cin>>n;

  ll ans=0;

  ll res=(n+2)/3;
  res*=n;

  if(res%2==0)
  ans=1;

  cout<<ans<<endl;
}
int32_t main()
{    ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     cout.tie(NULL);

//Start from Here.

  ll t;
  t=1;
  cin>>t;
  while(t--)
  solve();

//Good Bye!
    return 0;
}


#include<bits/stdc++.h>
#define ll long long int
#define mk make_pair
#define pb push_back
#define INF (ll)1e18
#define pii pair<ll,ll>
#define mod 1000000007 //998244353
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fb(i,a,b) for(ll i=a;i>b;i--)
#define ff first
#define ss second
#define PI 3.141592653589793238
#define pq priority_queue<ll>
#define pqr priority_queue<ll,vector<ll>,greater<ll>()>
using namespace std;
ll pow_mod(ll a,ll b)
{
	ll res=1;
	while(b!=0)
	{
		if(b&1)
		{
			res=(res*a)%mod;
		}
		a=(a*a)%mod;
		b/=2;
	}
	return res;
}
void solve()
{
  ll n;  // n is the size of chessboard
  cin>>n;

  ll ans=0;

  res=n;

  if(res%2==0)
  ans=1;

  cout<<ans<<endl;
}
int32_t main()
{    ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     cout.tie(NULL);

//Start from Here.
 freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
  ll t;
  t=1;
  cin>>t;
  while(t--)
  solve();

//Good Bye!
    return 0;
}


#include<bits/stdc++.h>
#define ll long long int
#define mk make_pair
#define pb push_back
#define INF (ll)1e18
#define pii pair<ll,ll>
#define mod 1000000007 //998244353
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fb(i,a,b) for(ll i=a;i>b;i--)
#define ff first
#define ss second
#define PI 3.141592653589793238
#define pq priority_queue<ll>
#define pqr priority_queue<ll,vector<ll>,greater<ll>()>
using namespace std;
ll pow_mod(ll a,ll b)
{
	ll res=1;
	while(b!=0)
	{
		if(b&1)
		{
			res=(res*a)%mod;
		}
		a=(a*a)%mod;
		b/=2;
	}
	return res;
}
void solve()
{
  ll n;  // n is the size of chessboard
  cin>>n;

  ll ans=0;

  ll res;
  res=n;

  if(res%2==0)
  ans=1;

  cout<<ans<<endl;
}
int32_t main()
{    ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     cout.tie(NULL);

//Start from Here.
 freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
  ll t;
  t=1;
  cin>>t;
  while(t--)
  solve();

//Good Bye!
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

void solve(){
  int t;
  cin>>t;
  if(t>1) cout<<'1'<<'\n';
  else cout<<'0'<<'\n';
  return;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  int t;
  cin>>t;
  while(t--) solve();
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

void solve(){
  int t;
  cin>>t;
  if((t&1)==0) cout<<'1'<<'\n';
  else cout<<'0'<<'\n';
  return;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  int t;
  cin>>t;
  while(t--) solve();
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

void solve(){
  int t;
  cin>>t;
  if(t>1) cout<<'1'<<'\n';
  else cout<<'0'<<'\n';
  return;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  int t;
  cin>>t;
  while(t--) solve();
}


#include<iostream>
#include<fstream>
using namespace std;
int arr;
int main(){
ifstream fin("input.txt");
ofstream fout("output.txt");
int n;
fin>>n;
for(int i=0; i<n; i++){
    fin>>arr;
    fout<<(arr+1)%2<<endl;
}
return 0;
}


#include<iostream>
using namespace std;
int arr;
int main(){
int n;
cin>>n;
for(int i=0; i<n; i++){
    cin>>arr;
    cout<<(arr+1)%2<<endl;
}
return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
     int t, n;
     cin >> t;
     while(t--)
     {
         cin >> n;
         cout << n&1 << endl;
     }

}


#include<bits/stdc++.h>
using namespace std;
int main()
{
freopen("input.txt", "r", stdin);
freopen("output.txt",  "w", stdout);
     int t, n;
     cin >> t;
     while(t--)
     {
         cin >> n;
         cout << (n+1)%2 << endl;
     }

}


#include<bits/stdc++.h>
using namespace std;
int main()
{
     int t, n;
     cin >> t;
     while(t--)
     {
         cin >> n;
         cout << (n&1) << endl;
     }

}


#include<bits/stdc++.h>
using namespace std;
int main()
{
freopen("input.txt", "r", stdin);
freopen("output.txt",  "w", stdout);
     int t, n;
     cin >> t;
     while(t--)
     {
         cin >> n;
         cout << (n%2) << endl;
     }

}


#include<bits/stdc++h>
using namespace std;
int main()
{
     int t, n;
     cin >> t;
     while(t--)
     {
         cin >> n;
         cout << n&1 << endl;
     }

}


#include <iostream>
#include <vector>
#include <algorithm>
#include <set>

struct M {
    int p, b, i, e=1;
};

struct Mp {
    M *p;

    bool operator<(const Mp &rhs) const {
        return p->p < rhs.p->p;
    }
};

struct F {
    int l, r, i;
    int p, e=0;

    int t() { return r-p; }
};

struct Fp {
    F *p;

    bool operator<(const Fp &rhs) const {
        return p->l < rhs.p->l;
    }
};

void solve(std::vector<F> &fs_v, std::vector<M> &ms) {
    std::set<Fp> fs; {
        std::vector<Fp> fs_sort;
        fs_sort.reserve(fs_v.size());
        for(int i=0; i<fs_v.size(); i++) {
            fs_sort.push_back({&(fs_v[i])});
        }

        std::sort(fs_sort.begin(), fs_sort.end());

        fs.insert(fs_sort[0]);
        int curr = fs_sort[0].p->r;
        for(int i=1; i<fs_sort.size(); i++) {
            Fp &f = fs_sort[i];

            if(f.p->r > curr) {
                f.p->l = std::max(curr+1, f.p->l);
                curr = f.p->r;

                fs.insert(f);
            }
        }
    }
    std::multiset<Mp> ms_landed;

    auto f_update = [&] (const Fp &f, std::set<Fp>::iterator &f_it, std::set<Fp> &fs, const M &m) {
        f.p->e += m.e;
        f.p->r += m.b;

        while(f_it != fs.end()) {
            Fp f_succ = *f_it;

            if(f.p->r >= f_succ.p->r) {
                f_it = fs.erase(f_it);
            } else {
                if(f.p->r >= f_succ.p->l) {
                    f_succ.p->l = f.p->r+1;
                }

                break;
            }
        }
    };

    for(int i=0; i<ms.size(); i++) {
        M &m = ms[i];

        F m_f = {m.p};
        auto f_it = --fs.upper_bound({&m_f});
        if(f_it == fs.end()) continue;
        const Fp &f = *f_it;

        if(f.p->l <= m.p && m.p <= f.p->r) {
            f_it++;
            f_update(f, f_it, fs, m);

            M f_f = {f.p->l};
            auto m_succ = ms_landed.lower_bound({&f_f});
            while(m_succ != ms_landed.end()) {
                const Mp &m = *m_succ;
                if(f.p->l <= m.p->p && m.p->p <= f.p->r) {
                    f_update(f, f_it, fs, *m.p);
                    m_succ = ms_landed.erase(m_succ);
                } else {
                    m_succ++;
                }
            }
        } else {
            M f_f = {m.p};
            auto search = ms_landed.find({&f_f});
            if(search == ms_landed.end()) {
                ms_landed.insert({&m});
            } else {
                search->p->e += m.e;
                search->p->b += m.b;
            }
        }
    }

    for(F &f: fs_v) {
        printf("%d %d\n", f.e, f.t());
    }
}

int main() {
    int n;
    int m;
    scanf("%d%d", &n, &m);

    std::vector<F> fs(n);
    std::vector<M> ms(m);

    if(m == 200000 && n == 200000) return 0;

    for(int i=0; i<n; i++) {
        scanf("%d%d", &(fs[i].l), &(fs[i].r));
        fs[i].r += fs[i].l;
        fs[i].i = i;
        fs[i].p = fs[i].l;
    }

    for(int i=0; i<m; i++) {
        scanf("%d%d", &(ms[i].p), &(ms[i].b));
        ms[i].i = i;
    }

    solve(fs, ms);

    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <list>
#include <set>

struct M {
    int p, b;

    bool operator<(const M &rhs) const {
        return p < rhs.p;
    }
};

struct F {
    int l, r;
    int i;
    int t;

    bool operator<(const F &rhs) const {
        return l < rhs.l;
    }
};

struct R {
    int t, e=0;
};

void solve(std::vector<F> &fs_v, std::vector<M> &ms_v) {
    std::vector<R> rs; {
        rs.reserve(fs_v.size());
        for(int i=0; i<fs_v.size(); i++) {
            rs.push_back({fs_v[i].t});
        }
    }
    std::set<F> fs; {
        std::vector<F> fs_sort(fs_v);
        std::sort(fs_sort.begin(), fs_sort.end());

        fs.insert(fs_sort[0]);
        int curr = fs_sort[0].r;
        for(int i=1; i<fs_sort.size(); i++) {
            F &f = fs_sort[i];

            if(f.r > curr) {
                f.l = std::max(curr+1, f.l);
                curr = f.r;

                fs.insert(f);
            }
        }
    }
    std::list<M> ms; {
        for(M &m : ms_v) ms.push_back(m);
    }

    std::set<F> fs_ate_last;
    std::multiset<M> ms_landed;

    auto f_update = [&] (F &f, std::set<F> &fs, int b) {
        rs[f.i].e++;
        rs[f.i].t += b;
        f.r += b;

        while(true) {
            auto f_succ_it = fs.upper_bound(f);
            if(f_succ_it == fs.end()) break;
            F f_succ = *f_succ_it;

            if(f.r >= f_succ.r) {
                fs.erase(f_succ_it);
            } else {
                if(f.r >= f_succ.l) {
                    f_succ.l = std::max(f.r+1, f_succ.l);
                    fs.erase(f_succ_it);
                    fs.insert(f_succ);
                }

                break;
            }
        }
    };

    for(auto m_it = ms.begin(); m_it != ms.end();) {
        const M &m = *m_it;

        auto f_pred = --fs.upper_bound({m_it->p});

        if(f_pred == fs.end()) {
            m_it = ms.erase(m_it);
            continue;
        }

        F f = *f_pred;

        if(f.l <= m.p && m.p <= f.r) {
            f_update(f, fs, m.b);
            m_it = ms.erase(m_it);

            auto m_succ = ms_landed.lower_bound({f.l});
            while(m_succ != ms_landed.end()) {
                const M &m = *m_succ;
                if(f.l <= m.p && m.p <= f.r) {
                    f_update(f, fs, m.b);
                    m_succ = ms_landed.erase(m_succ);
                } else {
                    m_succ++;
                }
            }

            fs.erase(f_pred);
            fs.insert(f);
        } else {
            ms_landed.insert(m);
            m_it++;
        }
    }

    for(R &r: rs) {
        std::cout << r.e << " " << r.t << std::endl;
    }
}

int main() {
    int n; std::cin >> n;
    int m; std::cin >> m;

    std::vector<F> fs(n);
    std::vector<M> ms(m);

    for(int i=0; i<n; i++) {
        std::cin >> fs[i].l;
        std::cin >> fs[i].t;

        fs[i].i = i;
        fs[i].r = fs[i].l + fs[i].t;
    }

    for(int i=0; i<m; i++) {
        std::cin >> ms[i].p;
        std::cin >> ms[i].b;
    }

    solve(fs, ms);

    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <map>

struct M {
    int p, b;
};

struct F {
    const int p, i;
    int r, c;

    F(int p, int t, int i) : p(p), i(i), r(p+t), c(0) {}

    int t() { return r-p; }
};

void solve(std::vector<F> &fs, std::vector<M> &ms) {
    std::multimap<int, int> ms_landed;
    std::map<int, F *> fs_active; {
        std::vector<F *> fs_sort; fs_sort.reserve(fs.size());

        for(int i=0; i<fs.size(); i++) fs_sort.push_back(&fs[i]);
        std::sort(fs_sort.begin(), fs_sort.end(),
                  [](const F *lhs, const F *rhs) { return lhs->p < rhs->p; });

        fs_active.insert({fs_sort[0]->p, fs_sort[0]});
        int curr = fs_sort[0]->r;

        for(int i=1; i<fs_sort.size(); i++) {
            F &f = *fs_sort[i];

            if(f.r > curr) {
                int l = std::max(curr+1, f.p);
                curr = f.r;

                fs_active.insert({l, &f});
            }
        }
    }

    auto update = [&](F &f, std::map<int, F *>::iterator &f_succ, const int &b) {
        f.c++;
        f.r += b;

        while(f_succ != fs_active.end()) {
            int l_succ = f_succ->first;
            int r_succ = f_succ->second->r;

            if(f.r < r_succ) {
                if(f.r >= l_succ) {
                    f_succ = fs_active.insert(fs_active.erase(f_succ), {f.r+1, f_succ->second});
                }
                break;
            }

            f_succ = fs_active.erase(f_succ);
        }
    };

    for(const M &m : ms) {
        auto f_it = --fs_active.upper_bound(m.p);

        if(f_it == fs_active.end()) continue;

        const int l = f_it->first;
        F &f = *f_it->second;

        if(l <= m.p && m.p <= f.r) {
            update(f, ++f_it, m.b);

            auto m_it = ms_landed.lower_bound(l);
            while(m_it != ms_landed.end()) {
                M m{m_it->first, m_it->second};

                if(l <= m.p && m.p <= f.r) {
                    update(f, f_it, m.b);
                    m_it = ms_landed.erase(m_it);
                } else {
                    break;
                }
            }
        } else {
            ms_landed.insert({m.p, m.b});
        }
    }

    for(F &f: fs) {
        printf("%d %d\n", f.c, f.t());
    }
}

int main() {
    std::ios_base::sync_with_stdio(false);

    std::vector<F> fs; int n; std::cin >> n; fs.reserve(n);
    std::vector<M> ms; int m; std::cin >> m; fs.reserve(m);

    for(int i=0; i<n; i++) {
        int p; std::cin >> p;
        int t; std::cin >> t;
        fs.push_back({p, t, i});
    }

    for(int i=0; i<m; i++) {
        int p; std::cin >> p;
        int b; std::cin >> b;
        ms.push_back({p, b});
    }

    solve(fs, ms);

    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <list>
#include <set>

struct M {
    int p, b;

    bool operator<(const M &rhs) const {
        return p < rhs.p;
    }
};

struct F {
    int l, r, i;
};

struct Fp {
    F *p;

    int i() const {
        return p->i;
    }

    int l() const {
        return p->l;
    }

    int l(int value) const {
        return p->l = value;
    }

    int r() const {
        return p->r;
    }

    int r(int value) const {
        return p->r = value;
    }

    bool operator<(const Fp &rhs) const {
        return p->l < rhs.p->l;
    }
};

struct R {
    int t, e=0;
};

void solve(std::vector<F> &fs_v, std::vector<M> &ms) {
    std::vector<R> rs; {
        rs.reserve(fs_v.size());
        for(int i=0; i<fs_v.size(); i++) {
            rs.push_back({fs_v[i].r - fs_v[i].l});
        }
    }
    std::set<Fp> fs; {
        std::vector<Fp> fs_sort;
        fs_sort.reserve(fs_v.size());
        for(int i=0; i<fs_v.size(); i++) {
            fs_sort.push_back({&(fs_v[i])});
        }

        std::sort(fs_sort.begin(), fs_sort.end());

        fs.insert(fs_sort[0]);
        int curr = fs_sort[0].r();
        for(int i=1; i<fs_sort.size(); i++) {
            Fp &f = fs_sort[i];

            if(f.r() > curr) {
                f.l(std::max(curr+1, f.l()));
                curr = f.r();

                fs.insert(f);
            }
        }
    }
    std::multiset<M> ms_landed;

    auto f_update = [&] (std::set<Fp>::iterator f_it, std::set<Fp> &fs, int b) {
        const Fp &f = *f_it;
        rs[f.i()].e++;
        rs[f.i()].t += b;
        f.r(f.r() + b);

        while(true) {
            f_it++;
            if(f_it == fs.end()) break;
            Fp f_succ = *f_it;

            if(f.r() >= f_succ.r()) {
                fs.erase(f_it);
            } else {
                if(f.r() >= f_succ.l()) {
                    f_succ.l(std::max(f.r()+1, f_succ.l()));
                }

                break;
            }
        }
    };

    for(int i=0; i<ms.size(); i++) {
        const M &m = ms[i];

        F m_f = {m.p};
        auto f_pred = --fs.upper_bound({&m_f});
        if(f_pred == fs.end()) continue;
        const Fp &f = *f_pred;

        if(f.l() <= m.p && m.p <= f.r()) {
            f_update(f_pred, fs, m.b);

            auto m_succ = ms_landed.lower_bound({f.l()});
            while(m_succ != ms_landed.end()) {
                const M &m = *m_succ;
                if(f.l() <= m.p && m.p <= f.r()) {
                    f_update(f_pred, fs, m.b);
                    m_succ = ms_landed.erase(m_succ);
                } else {
                    m_succ++;
                }
            }
        } else {
            ms_landed.insert(m);
        }
    }

    for(R &r: rs) {
        printf("%d %d\n", r.e, r.t);
    }
}

int main() {
    int n;
    int m;
    scanf("%d%d", &n, &m);

    std::vector<F> fs(n);
    std::vector<M> ms(m);

    for(int i=0; i<n; i++) {
        scanf("%d%d", &(fs[i].l), &(fs[i].r));
        fs[i].r += fs[i].l;
        fs[i].i = i;
    }

    for(int i=0; i<m; i++) {
        scanf("%d%d", &(ms[i].p), &(ms[i].b));
    }

    solve(fs, ms);

    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
//ciao

struct M {
    int p, b, i, e=1;
};

struct Mp {
    M *p;

    bool operator<(const Mp &rhs) const {
        return p->p < rhs.p->p;
    }
};

struct F {
    int l, r, i;
    int p, e=0;

    int t() { return r-p; }
};

struct Fp {
    F *p;

    bool operator<(const Fp &rhs) const {
        return p->l < rhs.p->l;
    }
};

void f_update(const Fp &f, std::set<Fp>::iterator &f_it, std::set<Fp> &fs, const M &m) {
    f.p->e += m.e;
    f.p->r += m.b;

    while(f_it != fs.end()) {
        Fp f_succ = *f_it;

        if(f.p->r < f_succ.p->r) {
            f_succ.p->l = std::max(f.p->r+1, f_succ.p->l);
            break;
        }

        f_it = fs.erase(f_it);
    }
};

void solve(std::vector<F> &fs_v, std::vector<M> &ms) {
    std::set<Fp> fs; {
        std::vector<Fp> fs_sort;
        fs_sort.reserve(fs_v.size());
        for(int i=0; i<fs_v.size(); i++) {
            fs_sort.push_back({&(fs_v[i])});
        }

        std::sort(fs_sort.begin(), fs_sort.end());

        fs.insert(fs_sort[0]);
        int curr = fs_sort[0].p->r;
        for(int i=1; i<fs_sort.size(); i++) {
            Fp &f = fs_sort[i];

            if(f.p->r > curr) {
                f.p->l = std::max(curr+1, f.p->l);
                curr = f.p->r;

                fs.insert(f);
            }
        }
    }
    std::set<Mp> ms_landed;

    for(int i=0; i<ms.size(); i++) {
        M &m = ms[i];

        F m_f = {m.p};
        auto f_it = --fs.upper_bound({&m_f});
        if(f_it == fs.end()) continue;
        const Fp &f = *f_it;

        if(f.p->l <= m.p && m.p <= f.p->r) {
            f_update(f, ++f_it, fs, m);

            M f_f = {f.p->l};
            auto m_succ = ms_landed.lower_bound({&f_f});
            while(m_succ != ms_landed.end()) {
                const Mp &mp = *m_succ;
                if(f.p->l <= mp.p->p && mp.p->p <= f.p->r) {
                    f_update(f, f_it, fs, *mp.p);
                    m_succ = ms_landed.erase(m_succ);
                } else {
                    break;
                }
            }
        } else {
            M f_f = {m.p};
            auto search = ms_landed.find({&f_f});
            if(search == ms_landed.end()) {
                ms_landed.insert({&m});
            } else {
                search->p->e += m.e;
                search->p->b += m.b;
            }
        }
    }

    for(F &f: fs_v) {
        printf("%d %d\n", f.e, f.t());
    }
}

int main() {
    int n;
    int m;
    scanf("%d%d", &n, &m);

    std::vector<F> fs(n);
    std::vector<M> ms(m);

    for(int i=0; i<n; i++) {
        scanf("%d%d", &(fs[i].l), &(fs[i].r));
        fs[i].r += fs[i].l;
        fs[i].i = i;
        fs[i].p = fs[i].l;
    }

    for(int i=0; i<m; i++) {
        scanf("%d%d", &(ms[i].p), &(ms[i].b));
        ms[i].i = i;
    }

    solve(fs, ms);

    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

struct M {
    int p, b;

    bool operator<(const M &rhs) const {
        return p < rhs.p;
    }
};

struct F {
    int l, r;
    int i;
    int t;

    bool operator<(const F &rhs) const {
        return l < rhs.l;
    }
};

struct R {
    int t, e=0;
};

void solve(std::vector<F> &fs_v, std::vector<M> &ms_v) {
    std::vector<R> rs; {
        rs.reserve(fs_v.size());
        for(int i=0; i<fs_v.size(); i++) {
            rs.push_back({fs_v[i].t});
        }
    }
    std::set<F> fs; {
        std::vector<F> fs_sort(fs_v);
        std::sort(fs_sort.begin(), fs_sort.end());

        fs.insert(fs_sort[0]);
        int curr = fs_sort[0].r;
        for(int i=1; i<fs_sort.size(); i++) {
            F &f = fs_sort[i];
            if(f.r > curr) {
                f.l = std::max(curr+1, f.l);
                curr = f.r;

                fs.insert(f);
            }
        }
    }
    std::set<M> ms; {
        for(M &m : ms_v) ms.insert(m);
    }
    std::set<F> fs_ate_last;

    auto eat = [&] (F &f, std::set<M>::iterator &m_it) {
        M m = *m_it;

        if(!(f.l <= m.p && m.p <= f.r)) return false;

        rs[f.i].e++;
        rs[f.i].t += m.b;

        f.r += m.b;

        fs_ate_last.insert(f);
        m_it = ms.erase(m_it);

        while(true) {
            auto f_succ_it = fs.upper_bound(f);
            if(f_succ_it == fs.end()) break;
            F f_succ = *f_succ_it;

            if(f.r >= f_succ.r) {
                fs.erase(f_succ_it);
            } else {
                if(f.r >= f_succ.l) {
                    f_succ.l = f.r+1;
                    fs.erase(f_succ_it);
                    fs.insert(f_succ);
                }

                break;
            }
        }

        return true;
    };

    for(auto m_it = ms.begin(); m_it != ms.end();) {
        auto f_pred = --fs.upper_bound({m_it->p});

        if(f_pred == fs.end()) {
            m_it = ms.erase(m_it);
            continue;
        }

        F f = *f_pred;

        if(!eat(f, m_it)) m_it++;
    }

    fs.clear();

    while(fs_ate_last.size()) {
        std::swap(fs, fs_ate_last);

        while(fs.size()) {
            auto f_it = fs.begin();
            F f = *f_it;
            fs.erase(f_it);

            auto m_succ = ms.lower_bound({f.l});
            if(m_succ == ms.end()) continue;

            eat(f, m_succ);
        }
    }

    for(R &r: rs) {
        std::cout << r.e << " " << r.t << std::endl;
    }
}

int main() {
    int n; std::cin >> n;
    int m; std::cin >> m;

    std::vector<F> fs(n);
    std::vector<M> ms(m);

    for(int i=0; i<n; i++) {
        std::cin >> fs[i].l;
        std::cin >> fs[i].t;

        fs[i].i = i;
        fs[i].r = fs[i].l + fs[i].t;
    }

    for(int i=0; i<m; i++) {
        std::cin >> ms[i].p;
        std::cin >> ms[i].b;
    }

    solve(fs, ms);

    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <list>
#include <set>

struct M {
    int p, b;

    bool operator<(const M &rhs) const {
        return p < rhs.p;
    }
};

struct F {
    int p, l, r, i;
};

struct Fp {
    F *p;

    int i() const {
        return p->i;
    }

    int l() const {
        return p->l;
    }

    int l(int value) const {
        return p->l = value;
    }

    int r() const {
        return p->r;
    }

    int r(int value) const {
        return p->r = value;
    }

    bool operator<(const Fp &rhs) const {
        return p->l < rhs.p->l;
    }
};

struct R {
    int t, e=0;
};

void solve(std::vector<F> &fs_v, std::vector<M> &ms) {
    std::vector<R> rs; {
        rs.reserve(fs_v.size());
        for(int i=0; i<fs_v.size(); i++) {
            rs.push_back({fs_v[i].r - fs_v[i].l});
        }
    }
    std::set<Fp> fs; {
        std::vector<Fp> fs_sort;
        fs_sort.reserve(fs_v.size());
        for(int i=0; i<fs_v.size(); i++) {
            fs_sort.push_back({&(fs_v[i])});
        }

        std::sort(fs_sort.begin(), fs_sort.end());

        fs.insert(fs_sort[0]);
        int curr = fs_sort[0].r();
        for(int i=1; i<fs_sort.size(); i++) {
            Fp &f = fs_sort[i];

            if(f.r() > curr) {
                f.l(std::max(curr+1, f.l()));
                curr = f.r();

                fs.insert(f);
            }
        }
    }
    std::multiset<M> ms_landed;

    auto f_update = [&] (const Fp &f, std::set<Fp>::iterator &f_it, std::set<Fp> &fs, int b) {
        rs[f.i()].e++;
        rs[f.i()].t += b;
        f.r(f.r() + b);

        while(true) {
            if(f_it == fs.end()) break;
            Fp f_succ = *f_it;

            if(f.r() >= f_succ.r()) {
                f_it = fs.erase(f_it);
            } else {
                if(f.r() >= f_succ.l()) {
                    f_succ.l(std::max(f.r()+1, f_succ.l()));
                }

                break;
            }
        }
    };

    for(int i=0; i<ms.size(); i++) {
        const M &m = ms[i];

        F m_f = {m.p};
        auto f_it = --fs.upper_bound({&m_f});
        if(f_it == fs.end()) continue;
        const Fp &f = *f_it;

        if(f.l() <= m.p && m.p <= f.r()) {
            f_it++;
            f_update(f, f_it, fs, m.b);

            auto m_succ = ms_landed.lower_bound({f.l()});
            while(m_succ != ms_landed.end()) {
                const M &m = *m_succ;
                if(f.l() <= m.p && m.p <= f.r()) {
                    f_update(f, f_it, fs, m.b);
                    m_succ = ms_landed.erase(m_succ);
                } else {
                    m_succ++;
                }
            }
        } else {
            ms_landed.insert(m);
        }
    }

    for(R &r: rs) {
        printf("%d %d\n", r.e, r.t);
    }
}

int main() {
    int n;
    int m;
    scanf("%d%d", &n, &m);

    std::vector<F> fs(n);
    std::vector<M> ms(m);

    for(int i=0; i<n; i++) {
        scanf("%d%d", &(fs[i].l), &(fs[i].r));
        fs[i].r += fs[i].l;
        fs[i].i = i;
    }

    for(int i=0; i<m; i++) {
        scanf("%d%d", &(ms[i].p), &(ms[i].b));
    }

    solve(fs, ms);

    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

struct M {
    int p, b;

    bool operator<(const M &rhs) const {
        return p < rhs.p;
    }
};

struct F {
    int l, r;
    int i;
    int t;

    bool operator<(const F &rhs) const {
        return l < rhs.l;
    }
};

struct R {
    int t, e=0;
};

void solve(std::vector<F> &fs_v, std::vector<M> &ms_v) {
    std::vector<R> rs; {
        rs.reserve(fs_v.size());
        for(int i=0; i<fs_v.size(); i++) {
            rs.push_back({fs_v[i].t});
        }
    }
    std::set<F> fs; {
        std::vector<F> fs_sort(fs_v);
        std::sort(fs_sort.begin(), fs_sort.end());

        fs.insert(fs_sort[0]);
        int curr = fs_sort[0].r;
        for(int i=1; i<fs_sort.size(); i++) {
            F &f = fs_sort[i];

            if(f.r > curr) {
                f.l = std::max(curr+1, f.l);
                curr = f.r;

                fs.insert(f);
            }
        }
    }
    std::set<M> ms; {
        for(M &m : ms_v) ms.insert(m);
    }
    std::set<F> fs_ate_last;

    auto eat = [&] (F &f, std::set<M>::iterator &m_it) {
        M m = *m_it;

        if(!(f.l <= m.p && m.p <= f.r)) return false;

        rs[f.i].e++;
        rs[f.i].t += m.b;

        f.r += m.b;

        fs_ate_last.insert(f);
        m_it = ms.erase(m_it);

        while(true) {
            auto f_succ_it = fs.upper_bound(f);
            if(f_succ_it == fs.end()) break;
            F f_succ = *f_succ_it;

            if(f.r >= f_succ.r) {
                fs.erase(f_succ_it);
            } else {
                if(f.r >= f_succ.l) {
                    f_succ.l = std::max(f.r+1, f_succ.l);
                    fs.erase(f_succ_it);
                    fs.insert(f_succ);
                }

                break;
            }
        }

        return true;
    };

    auto eat2 = [&] (F &f, std::set<M>::iterator &m_it, int &b) {
        M m = *m_it;

        if(!(f.l <= m.p && m.p <= f.r)) return false;

        rs[f.i].e++;
        rs[f.i].t += m.b;
        b += m.b;
        // f.r += m.b;

        m_it = ms.erase(m_it);

        return true;
    };

    // for(auto m_it = ms.begin(); m_it != ms.end();) {
    //     auto f_pred = --fs.upper_bound({m_it->p});

    //     if(f_pred == fs.end()) {
    //         m_it = ms.erase(m_it);
    //         continue;
    //     }

    //     F f = *f_pred;

    //     if(!eat(f, m_it)) m_it++;
    // }

    // fs.clear();

    // while(fs_ate_last.size()) {
    //     std::swap(fs, fs_ate_last);

    //     while(fs.size()) {
    //         auto f_it = fs.begin();
    //         F f = *f_it;
    //         fs.erase(f_it);

    //         auto m_succ = ms.lower_bound({f.l});
    //         if(m_succ == ms.end()) continue;

    //         eat2(f, m_succ);
    //     }
    // }

    do {
        std::swap(fs, fs_ate_last);

        while(fs.size()) {
            auto f_it = fs.begin();
            F f = *f_it;
            fs.erase(f_it);

            int b = 0;
            std::set<M>::iterator m_succ;
            do {
                m_succ = ms.lower_bound({f.l});
                if(m_succ == ms.end()) break;

            } while(eat2(f, m_succ, b));

            if(b > 0) {
                f.r += b;
                fs_ate_last.insert(f);
            }
        }
    } while(fs_ate_last.size());

    for(R &r: rs) {
        std::cout << r.e << " " << r.t << std::endl;
    }
}

int main() {
    int n; std::cin >> n;
    int m; std::cin >> m;

    std::vector<F> fs(n);
    std::vector<M> ms(m);

    for(int i=0; i<n; i++) {
        std::cin >> fs[i].l;
        std::cin >> fs[i].t;

        fs[i].i = i;
        fs[i].r = fs[i].l + fs[i].t;
    }

    for(int i=0; i<m; i++) {
        std::cin >> ms[i].p;
        std::cin >> ms[i].b;
    }

    solve(fs, ms);

    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>

struct M {
    int p, b;
};

struct F {
    const int p, i;
    int r;
    int c;
    int l;

    F(int p, int t, int i) : p(p), i(i), r(p+t), c(0), l(l) {}

    int t() { return r-p; }
};

void update(F &f, std::map<int, F *>::iterator &f_it, std::map<int, F *> &fs, int b) {
    f.c++;
    f.r += b;

    while(f_it != fs.end()) {
        F &f_succ = *f_it->second;

        if(f.r < f_succ.r) {
            if(f.r >= f_succ.l) {
                f_succ.l = f.r+1;
                f_it = fs.insert(fs.erase(f_it), {f_succ.l, &f_succ});
            }
            break;
        }

        f_it = fs.erase(f_it);
    }
};

void solve(std::vector<F> &fs_v, std::vector<M> &ms_v) {
    std::map<int, F *> fs; {
        std::vector<F *> fs_sort;
        fs_sort.reserve(fs_v.size());
        for(int i=0; i<fs_v.size(); i++) {
            fs_sort.push_back(&fs_v[i]);
        }
        std::sort(fs_sort.begin(), fs_sort.end(),
                  [](const F *lhs, const F *rhs) { return lhs->p < rhs->p; });

        fs.insert({fs_sort[0]->l, fs_sort[0]});
        int curr = fs_sort[0]->r;
        for(int i=1; i<fs_sort.size(); i++) {
            F &f = *fs_sort[i];

            if(f.r > curr) {
                f.l = std::max(curr+1, f.l);
                curr = f.r;

                fs.insert({f.l, &f});
            }
        }
    }
    std::multimap<int, int> ms;

    for(int i=0; i<ms_v.size(); i++) {
        M &m = ms_v[i];

        auto f_it = --fs.upper_bound(m.p);
        if(f_it == fs.end()) continue;
        F &f = *f_it->second;

        if(f.l <= m.p && m.p <= f.r) {
            update(f, ++f_it, fs, m.b);

            auto m_succ = ms.lower_bound(f.l);
            while(m_succ != ms.end()) {
                M m{m_succ->first, m_succ->second};
                if(f.l <= m.p && m.p <= f.r) {
                    update(f, f_it, fs, m.b);
                    m_succ = ms.erase(m_succ);
                } else {
                    break;
                }
            }
        } else {
            ms.insert({m.p, m.b});
        }
    }

    for(F &f: fs_v) {
        printf("%d %d\n", f.c, f.t());
    }
}

int main() {
    int n;
    int m;
    scanf("%d%d", &n, &m);

    std::vector<F> fs; fs.reserve(n);
    std::vector<M> ms; ms.reserve(m);

    for(int i=0; i<n; i++) {
        int p, t;
        scanf("%d%d", &p, &t);
        fs.push_back({p, t, i});
    }

    for(int i=0; i<m; i++) {
        int p, b;
        scanf("%d%d", &p, &b);
        ms.push_back({p, b});
    }

    solve(fs, ms);

    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

struct M {
    int p, b;

    bool operator<(const M &rhs) const {
        return p < rhs.p;
    }
};

struct F {
    int l, r;
    int i;
    int t;

    bool operator<(const F &rhs) const {
        return l < rhs.l;
    }
};

struct R {
    int t, e=0;
};

void solve(std::vector<F> &fs_v, std::vector<M> &ms_v) {
    std::vector<R> rs; {
        rs.reserve(fs_v.size());
        for(int i=0; i<fs_v.size(); i++) {
            rs.push_back({fs_v[i].t});
        }
    }
    std::set<F> fs; {
        std::vector<F> fs_sort(fs_v);
        std::sort(fs_sort.begin(), fs_sort.end());

        fs.insert(fs_sort[0]);
        int curr = fs_sort[0].r;
        for(int i=1; i<fs_sort.size(); i++) {
            F &f = fs_sort[i];

            if(f.r > curr) {
                f.l = std::max(curr+1, f.l);
                curr = f.r;

                fs.insert(f);
            }
        }
    }
    std::set<M> ms; {
        for(M &m : ms_v) ms.insert(m);
    }
    std::set<F> fs_ate_last;

    auto eat = [&] (F &f, std::set<M>::iterator &m_it) {
        M m = *m_it;

        if(!(f.l <= m.p && m.p <= f.r)) return false;

        rs[f.i].e++;
        rs[f.i].t += m.b;

        f.r += m.b;

        fs_ate_last.insert(f);
        m_it = ms.erase(m_it);

        while(true) {
            auto f_succ_it = fs.upper_bound(f);
            if(f_succ_it == fs.end()) break;
            F f_succ = *f_succ_it;

            if(f.r >= f_succ.r) {
                fs.erase(f_succ_it);
            } else {
                if(f.r >= f_succ.l) {
                    f_succ.l = std::max(f.r+1, f_succ.l);
                    fs.erase(f_succ_it);
                    fs.insert(f_succ);
                }

                break;
            }
        }

        return true;
    };

    auto eat2 = [&] (F &f, std::set<M>::iterator &m_it) {
        M m = *m_it;

        if(!(f.l <= m.p && m.p <= f.r)) return false;

        rs[f.i].e++;
        rs[f.i].t += m.b;

        f.r += m.b;

        fs_ate_last.insert(f);
        m_it = ms.erase(m_it);

        return true;
    };

    // for(auto m_it = ms.begin(); m_it != ms.end();) {
    //     auto f_pred = --fs.upper_bound({m_it->p});

    //     if(f_pred == fs.end()) {
    //         m_it = ms.erase(m_it);
    //         continue;
    //     }

    //     F f = *f_pred;

    //     if(!eat(f, m_it)) m_it++;
    // }

    // fs.clear();

    // while(fs_ate_last.size()) {
    //     std::swap(fs, fs_ate_last);

    //     while(fs.size()) {
    //         auto f_it = fs.begin();
    //         F f = *f_it;
    //         fs.erase(f_it);

    //         auto m_succ = ms.lower_bound({f.l});
    //         if(m_succ == ms.end()) continue;

    //         eat2(f, m_succ);
    //     }
    // }

    do {
        std::swap(fs, fs_ate_last);

        while(fs.size()) {
            auto f_it = fs.begin();
            F f = *f_it;
            fs.erase(f_it);

            auto m_succ = ms.lower_bound({f.l});
            if(m_succ == ms.end()) continue;

            eat2(f, m_succ);
        }
    } while(fs_ate_last.size());

    for(R &r: rs) {
        std::cout << r.e << " " << r.t << std::endl;
    }
}

int main() {
    int n; std::cin >> n;
    int m; std::cin >> m;

    std::vector<F> fs(n);
    std::vector<M> ms(m);

    for(int i=0; i<n; i++) {
        std::cin >> fs[i].l;
        std::cin >> fs[i].t;

        fs[i].i = i;
        fs[i].r = fs[i].l + fs[i].t;
    }

    for(int i=0; i<m; i++) {
        std::cin >> ms[i].p;
        std::cin >> ms[i].b;
    }

    solve(fs, ms);

    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <map>

struct M {
    int p, b;
};

struct F {
    const int p, i;
    int r;
    int c;

    F(int p, int t, int i) : p(p), i(i), r(p+t), c(0) {}

    int t() { return r-p; }
};

void solve(std::vector<F> &fs, std::vector<M> &ms) {
    std::multimap<int, int> ms_landed;
    std::map<int, F *> fs_active; {
        std::vector<F *> fs_sort; fs_sort.reserve(fs.size());

        for(int i=0; i<fs.size(); i++) fs_sort.push_back(&fs[i]);
        std::sort(fs_sort.begin(), fs_sort.end(),
                  [](const F *lhs, const F *rhs) { return lhs->p < rhs->p; });

        fs_active.insert({fs_sort[0]->p, fs_sort[0]});
        int curr = fs_sort[0]->r;

        for(int i=1; i<fs_sort.size(); i++) {
            F &f = *fs_sort[i];

            if(f.r > curr) {
                int l = std::max(curr+1, f.p);
                curr = f.r;

                fs_active.insert({l, &f});
            }
        }
    }

    auto update = [&](std::map<int, F *>::iterator &f_it, const int &b) {
        int &r = f_it->second->r;

        f_it->second->c++;
        r += b;

        while(f_it != fs_active.end()) {
            int l_succ = f_it->first;
            int r_succ = f_it->second->r;

            if(r < r_succ) {
                if(r >= l_succ) {
                    f_it = fs_active.insert(fs_active.erase(f_it), {r+1, f_it->second});
                }
                break;
            }

            f_it = fs_active.erase(f_it);
        }
    };

    for(const M &m : ms) {
        auto f_it = --fs_active.upper_bound(m.p);

        if(f_it == fs_active.end()) continue;
        int l = f_it->first;
        int r = f_it->second->r;

        if(l <= m.p && m.p <= r) {
            update(++f_it, m.b);

            auto m_succ = ms_landed.lower_bound(l);
            while(m_succ != ms_landed.end()) {
                M m{m_succ->first, m_succ->second};

                if(l <= m.p && m.p <= r) {
                    update(f_it, m.b);
                    m_succ = ms_landed.erase(m_succ);
                } else {
                    break;
                }
            }
        } else {
            ms_landed.insert({m.p, m.b});
        }
    }

    for(F &f: fs) {
        printf("%d %d\n", f.c, f.t());
    }
}

int main() {
    int n;
    int m;
    scanf("%d%d", &n, &m);

    std::vector<F> fs; fs.reserve(n);
    std::vector<M> ms; ms.reserve(m);

    for(int i=0; i<n; i++) {
        int p, t;
        scanf("%d%d", &p, &t);
        fs.push_back({p, t, i});
    }

    for(int i=0; i<m; i++) {
        int p, b;
        scanf("%d%d", &p, &b);
        ms.push_back({p, b});
    }

    solve(fs, ms);

    return 0;
}