#include using namespace std; #define FOR(a,b,c) for(int a = b; a < c; a++) #define all(a) (a).begin(),(a).end() const int N = 2e5 + 7; int grupa[N * 55]; bool isWater[N * 55]; int getId(int x,int y) { return x * N + y; } int Find(int a) { if(grupa[a] == a)return a; return grupa[a] = Find(grupa[a]); } void Union(int a,int b) { a = Find(a); b = Find(b); grupa[a] = b; } set S[55]; int DX[4] = {1,-1,0,0}; int DY[4] = {0,0,1,-1}; const int MAXN = 2e5; void merge(int x,int y1,int y2,int id) { auto p = S[x].lower_bound(y1); while(p != S[x].end() and *p <= y2) { auto it = p; it++; isWater[getId(x, *p)] = 1; FOR(d,0,4) { int nx = DX[d] + x; int ny = DY[d] + *p; if(nx >= 1 and nx <= 50 and ny >= 1 and ny <= MAXN and isWater[getId(nx, ny)]) { Union(getId(x,*p),getId(nx,ny)); } } S[x].erase(p); p = it; } } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); FOR(i,0,N * 55) grupa[i] = i; FOR(x,0,55) { FOR(i,1,N)S[x].insert(i); } int L; cin >> L; int curId = 1; while(L--) { int t, x1, y1, x2, y2; cin >> t >> x1 >> y1 >> x2 >> y2; if(t == 0) { FOR(x,x1,x2 + 1)merge(x,y1,y2,curId); curId++; } else { int a = Find(getId(x1,y1)); int b = Find(getId(x2,y2)); cout << (a == b and a != 0) << "\n"; } } return 0; }