#include using namespace std; pair parent[51][100001]; int size[51][100001]; set fields[51]; void init(){ for(int i=0;i<51;i++){ for(int j=0;j<100001;j++){ fields[i].insert(j); parent[i][j] = {i, j}; } } } pair findParent(pair a){ while(parent[a.first][a.second]!=a){ a = parent[a.first][a.second]; } return a; } void Uni(pair a, pair b){ a = findParent(a); b = findParent(b); if(a==b) return; if(size[a.first][a.second] >= size[b.first][b.second]){ size[a.first][a.second]++; parent[b.first][b.second] = a; } else{ size[b.first][b.second]++; parent[a.first][a.second] = b; } } vector > moves{{0,1}, {0, -1}, {1, 0}, {-1, 0}}; void around(pair a){ for(auto &i:moves){ auto tmp = a; tmp.first += i.first; tmp.second += i.second; if(!fields[tmp.first].count(tmp.second)) Uni(a, tmp); } } void addLine(int x, int down, int top){ auto it = fields[x].lower_bound(down); while(it!= fields[x].end() && *it <= top){ auto tmp = it; tmp++; around({x, *it}); fields[x].erase(it); it = tmp; } } void add(pair a, pair b){ for(int i=a.first; i<= b.first;i++){ addLine(i, a.second, b.second); } } main(){ init(); int l; cin >> l; while(l--){ int t; pair a,b; cin >> t >> a.first >> a.second >> b.first >> b.second; if(t==0){ add(a, b); } else{ cout << (findParent(a) == findParent(b)) << endl; } } return 0; }