#include using namespace std; const int H = 60; const int W = 100000+10; pair parent[H][W]; int size[H][W]; set fields[H]; void init(){ for(int i=0;i 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){ if(fields[x].empty()) return; 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; if(b> t >> a.first >> a.second >> b.first >> b.second; if(t==0){ add(a, b); } else{ cout << (findParent(a) == findParent(b)) << endl; } } return 0; }