//package island; import java.util.Scanner; class DisjoinSet { int[] par; int[] ranks; public DisjoinSet(int size) { par = new int[size]; ranks = new int[size]; for (int i = 0; i < size; i++) { par[i] = i; ranks[i] = 1; } } int find(int x) { return x == par[x] ? x : (par[x] = find(par[x])); } void union(int x, int y) { int px = find(x); int py = find(y); if (px != py) { if (ranks[py] > ranks[px]) par[px] = py; else { par[py] = px; if (ranks[py] == ranks[px]) ranks[py]++; } } } @Override public String toString() { String s = ""; for (int i = 0; i < par.length; i++) s += par[i] + " "; return s; } } class Rectangle { int lx, ly, rx, ry; public Rectangle(int lx, int ly, int rx, int ry) { this.lx = Math.min(lx,rx); this.ly = Math.min(ly,ry); this.rx = Math.max(rx,lx); this.ry = Math.max(ry,ly); } public boolean isInside(Rectangle rect) { if(rect.rx < lx - 1) return false; if(rect.lx > rx + 1) return false; if(rect.ry < ly - 1) return false; if(rect.ly > ry + 1) return false; return true; } public boolean isInside(int x, int y) { return x >= lx && x <= rx && y >= ly && y <= ry; } } public class Island { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int type; int lx, ly, rx, ry; DisjoinSet ds = new DisjoinSet(n); Rectangle[] rects = new Rectangle[n]; int rectCount = 0; for (int i = 0; i < n; i++) { type = sc.nextInt(); if (type == 0) { lx = sc.nextInt(); ly = sc.nextInt(); rx = sc.nextInt(); ry = sc.nextInt(); rects[rectCount] = new Rectangle(lx, ly, rx, ry); for (int j = rectCount - 1; j >= 0; j--) if (rects[rectCount].isInside(rects[j])) { ds.union(rectCount, j); } rectCount++; continue; } if (type == 1) { // System.out.println(ds); lx = sc.nextInt(); ly = sc.nextInt(); rx = sc.nextInt(); ry = sc.nextInt(); boolean f1 = false; boolean f2 = false; int o1=0, o2=0; for (int j = 0; j < rectCount; j++) { if (f1 && f2) break; if (!f1 && rects[j].isInside(lx, ly)) { f1 = true; o1 = j; } if (!f2 && rects[j].isInside(rx, ry)) { f2 = true; o2 = j; } } if (!f1 || !f2) { System.out.println(0); } else { int px = ds.find(o1); int py = ds.find(o2); if (px == py) System.out.println(1); else System.out.println(0); } } } } }