#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



#define SIZE 800005
typedef pair<int,int> P;

enum Type{
	TATE,
	YOKO,
};

struct Line{

	int x1,y1,x2,y2;
};

int N;
vector<int> X,Y;
set<int> table[2][SIZE];
set<P> SET[2][SIZE];
map<int,int> map_X,map_Y;
Type rev[2] = {YOKO,TATE};
Line line[SIZE];

//簡易化のため、要素数を2のべき乗にする関数
void init(int first_N){
	while(N < first_N)N *= 2;
}

void add(int left,int right,int value,int node_id,int node_left,int node_right,Type type){

	if(right < node_left || left > node_right)return;
	else if(left <= node_left && right >= node_right){

		table[type][node_id].insert(value);

	}else{
		add(left,right,value,2*node_id+1,node_left,(node_left+node_right)/2,type);
		add(left,right,value,2*node_id+2,(node_left+node_right)/2+1,node_right,type);
	}
}

bool isCross(int loc,int mini,int maxi,Type type){

	loc += N-1;

	while(true){

		if(table[type][loc].lower_bound(mini) != table[type][loc].upper_bound(maxi)){

			return true;
		}
		if(loc == 0){

			return false;
		}
		loc = (loc-1)/2;
	}
	return false;
}


int main(){

	int first_N;
	scanf("%d",&first_N);

	for(int i = 0; i < first_N; i++){

		scanf("%d %d %d %d",&line[i].x1,&line[i].y1,&line[i].x2,&line[i].y2);

		X.push_back(line[i].x1);
		X.push_back(line[i].x2);
		Y.push_back(line[i].y1);
		Y.push_back(line[i].y2);
	}

	sort(X.begin(),X.end());
	X.erase(unique(X.begin(),X.end()),X.end());
	for(int i = 0; i < X.size(); i++){

		map_X[X[i]] = i;
	}

	sort(Y.begin(),Y.end());
	Y.erase(unique(Y.begin(),Y.end()),Y.end());
	for(int i = 0; i < Y.size(); i++){

		map_Y[Y[i]] = i;
	}

	N = 1;
	init(2*first_N); //★★1つの線分につき2点あるから、2*first_Nで初期化する★★
	Type type;
	int loc,mini,maxi;

	for(int i = 0; i < first_N; i++){

		if(line[i].x1 == line[i].x2){

			type = TATE;
			loc = map_X[line[i].x1];
			mini = map_Y[min(line[i].y1,line[i].y2)];
			maxi = map_Y[max(line[i].y1,line[i].y2)];

		}else{

			type = YOKO;
			loc = map_Y[line[i].y1];
			mini = map_X[min(line[i].x1,line[i].x2)];
			maxi = map_X[max(line[i].x1,line[i].x2)];
		}

		//垂直交差チェック
		if(isCross(loc,mini,maxi,rev[type])){

			printf("0\n");
			continue;
		}

		//水平交差チェック
		auto at = SET[type][loc].lower_bound(make_pair(mini,maxi));
		//右側チェック
		if(at != SET[type][loc].end()){

			if(maxi < at->first || mini > at->second){

				//Do nothing
			}else{
				printf("0\n");
				continue;
			}
		}
		//左側チェック
		if(at != SET[type][loc].begin()){

			at--;
			if(maxi < at->first || mini > at->second){

				//Do nothing
			}else{
				printf("0\n");
				continue;
			}
		}

		printf("1\n");
		add(mini,maxi,loc,0,0,N-1,type);
		SET[type][loc].insert(make_pair(mini,maxi));
	}

	return 0;
}

