import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Set;
import java.util.StringTokenizer;

public class billboard_sm {
	class Paper {
		Set<Point> gs;
		int x1, y1, x2, y2;

		public Paper(int x1, int y1, int x2, int y2) {
			this.x1 = x1;
			this.y1 = y1;
			this.x2 = x2;
			this.y2 = y2;
			assert 0 <= x1 && x1 <= x2 && x2 <= w;
			assert 0 <= y1 && y1 <= y2 && y2 <= h;
			gs = new HashSet<Point>();
		}

		public boolean contains(Point p) {
			return x1 <= p.x && p.x <= x2 && y1 <= p.y && p.y <= y2;
		}
	}

	class Point {
		int x, y;
		Set<Paper> papers;

		public Point(int x, int y) {
			papers = new HashSet<Paper>();
			this.x = x;
			this.y = y;
		}

	}

	Set<Paper> papers;
	int w, h;

	void solve() {
		w = nextInt();
		assert 5 <= w && w <= 1e8;
		h = nextInt();
		assert 5 <= h && h <= 1e8;
		int n = nextInt();
		papers = new HashSet<Paper>();
		ArrayList<Paper> allPaper = new ArrayList<Paper>();
		ArrayList<Point> allPoint = new ArrayList<Point>();
		for (int it = 0; it < n; it++) {
			int op = nextInt();
			if (op == 1) {
				Paper paper = new Paper(nextInt(), nextInt(), nextInt(), nextInt());
				papers.add(paper);
				allPaper.add(paper);
				Point g = new Point(nextInt(), nextInt());
				allPoint.add(g);
				for (Paper p : papers) {
					if (p.contains(g)) {
						p.gs.add(g);
						g.papers.add(p);
					}
				}
			} else if (op == 2) {
				int k = nextInt() - 1;
				if (!papers.contains(allPaper.get(k))) {
					continue;
				}
				kill(allPaper.get(k));
			} else if (op == 3) {
				int k = nextInt() - 1;
				if (!papers.contains(allPaper.get(k))) {
					out.println(0);
				} else {
					out.println(allPaper.get(k).gs.size());
				}
			} else if (op == 4) {
				out.println(papers.size());
			} else {
				throw new AssertionError();
			}
		}
	}

	private void kill(Paper paper) {
		papers.remove(paper);
		for (Point g : paper.gs) {
			for (Paper pp : g.papers) {
				if (pp == paper)
					continue;
				pp.gs.remove(g);
				if (pp.gs.isEmpty()) {
					papers.remove(pp);
				}
			}
		}
	}

	BufferedReader br;
	StringTokenizer st;
	PrintWriter out;

	public void run() {
		try {
			String filename = this.getClass().getName().substring(0, this.getClass().getName().indexOf("_"));
			br = new BufferedReader(new FileReader(filename + ".in"));
			out = new PrintWriter(filename + ".out");
			solve();
			out.close();
		} catch (IOException e) {
			e.printStackTrace();
			System.exit(1);
		}
	}

	String nextToken() {
		try {
			while (st == null || !st.hasMoreTokens()) {
				String s = br.readLine();
				if (s == null) {
					return null;
				}
				st = new StringTokenizer(s);
			}
			return st.nextToken();
		} catch (IOException e) {
			throw new RuntimeException();
		}
	}

	int nextInt() {
		return Integer.parseInt(nextToken());
	}

	long nextLong() {
		return Integer.parseInt(nextToken());
	}

	public static void main(String[] args) {
		new billboard_sm().run();
	}
}
