#include using namespace std; #define PII pair #define VI vector #define VPII vector #define LL long long #define f first #define s second #define MP make_pair #define PB push_back #define LD long double #define endl '\n' #define ALL(c) (c).begin(), (c).end() #define SIZ(c) (int)(c).size() #define REP(i, n) for (int i = 0; i < (int)(n); i++) #define FOR(i, b, e) for (int i = (b); i <= (int)(e); i++) #define FORD(i, b, e) for (int i = (b); i >= (int)(e); i--) #define ll LL #define mp MP #define pb PB #define st f #define nd s #define eb emplace_back const int inf = 1e9 + 7; const LL INF = 1e18L + 7; #define sim template ostream & operator << (ostream &p, pair x) {return p << "<" << x.f << ", " << x.s << ">";} sim> auto operator << (ostream &p, n y) -> typename enable_if::value, decltype(y.begin(), p)>::type {int o = 0; for (auto c : y) {if (o++) p << ", "; p << c;} return p << "}";} void dor() {cerr << endl;} sim, class...s> void dor(n p, s...y) {cerr << p << " "; dor(y...);} sim, class s> void mini(n &p, s y) {if (p > y) p = y;} sim, class s> void maxi(n &p, s y) {if (p < y) p = y;} #ifdef DEB #define debug(...) dor(__FUNCTION__, ":", __LINE__, ": ", __VA_ARGS__) #else #define debug(...) #endif #define I(x) #x " =", (x), " " #define A(a, i) #a "[" #i " =", i, "] =", a[i], " " #define y1 ahahahha const int N = 1e5+7; const int nax = 1e5; int repAll[57*N]; int ena[57][N]; int FindAll(int a) { if(a!=repAll[a]) repAll[a] = FindAll(repAll[a]); return repAll[a]; } void UnionAll(int a, int b) { a = FindAll(a); b = FindAll(b); repAll[a] = b; } int nr(int x, int y) { return nax*(x-1) + y; } struct male { int row; int rep[N]; int prawo[N]; int Find(int a) { if(a!=rep[a]) rep[a] = Find(rep[a]); return rep[a]; } void Union(int a, int b) { a = Find(a); b = Find(b); rep[a] = b; prawo[b] = max(prawo[b], prawo[a]); } void wlacz(int a) { ena[row][a] = 1; int ten = nr(row, a); if(ena[row][a-1]) { Union(a, a-1); UnionAll(ten, nr(row, a-1)); } if(ena[row][a+1]) { Union(a, a+1); UnionAll(ten, nr(row, a+1)); } if(ena[row-1][a]) { UnionAll(ten, nr(row-1, a)); } if(ena[row+1][a]) { UnionAll(ten, nr(row+1, a)); } } void przedzial(int a, int b) { if(!ena[row][a]) wlacz(a); while(prawo[Find(a)]+1<=b) { wlacz(prawo[Find(a)]+1); } } }; male M[51]; int l; int main() { ios_base::sync_with_stdio(0); cin.tie(NULL); for(int i = 1; i <= 50; ++i) { M[i].row = i; for(int j = 1; j <= nax; ++j) { M[i].rep[j] = M[i].prawo[j] = j; repAll[nr(i, j)] = nr(i, j); } } cin >> l; while(l--) { int t, x1, y1, x2, y2; cin >> t >> x1 >> y1 >> x2 >> y2; if(t==0) { if(x1>x2) swap(x1, x2); if(y1>y2) swap(y1, y2); for(int i = x1; i <= x2; ++i) { M[i].przedzial(y1, y2); } } else { int a = nr(x1, y1); int b = nr(x2, y2); if(ena[x1][y1] && ena[x2][y2] && FindAll(a)==FindAll(b)) cout << 1 << endl; else cout << 0 << endl; } } }