#include "bits/stdc++.h" using namespace std; #define LL long long #define int LL #define PB push_back #define VI vector #define FOR(i,a,b) for(int i = (a); i <= (b); i++) #define REP(i,n) FOR(i, 0, (int)n - 1) #define PII pair #define ALL(x) (x).begin(), (x).end() #define SZ(x) ((int)(x).size()) #define st first #define nd second template void mini(C & a4, C b4){a4 = min(a4, b4);} template void maxi(C & a4, C b4){a4 = max(a4, b4);} template void _dbg(const char * sdbg, TH h){ cerr< void _dbg(const char * sdbg, TH h, TA... a){ while(*sdbg!=',') cerr<<*sdbg++; cerr<<'='< ostream & operator<<(ostream & os, vector V){ os<<"[";for(auto vv: V) os < ostream & operator<<(ostream & os , pair P){ return os << "(" << P.st <<","<= yFrom) { for (int i = 0; i < 4; i++) { int xx = x + dx[i]; int yy = y + dy[i]; if (done[xx][yy]) { Union(id(x, y), id(xx, yy)); } } done[x][y] = true; } if (y - 1 >= yFrom) { Union(id(x, y), id(x, y - 1)); jumpArr[x][y] = y - 1; } else { break; } } } void insert(int xFrom, int yFrom, int xTo, int yTo) { for (int x = xFrom; x <= xTo; x++) { joinPath(x, yFrom, yTo); if (x < xTo) { connectPaths(x, x + 1, yTo); } } } int32_t main(){ ios_base::sync_with_stdio(0); cin.tie(0); for (int i = 1; i <= MAX_X; i++) { for (int j = 1; j <= MAX_Y; j++) { rep[id(i,j)] = id(i, j); jumpArr[i][j] = j; } } cin >> q; while (q--) { int t, xFrom, xTo, yFrom, yTo; cin >> t >> xFrom >> yFrom >> xTo >> yTo; if (t == 0) { if (xFrom > xTo) { swap(xFrom, xTo); } if (yFrom > yTo) { swap(yFrom, yTo); } } if (t == 0) { insert(xFrom, yFrom, xTo, yTo); } else { if (find(id(xFrom, yFrom)) == find(id(xTo, yTo))) { cout << 1 << "\n"; } else { cout << 0 << "\n"; } } } }