import java.io.*;
import java.util.*;

public class billboard_sk implements Runnable {
	public static void main(String[] args) {
		Locale.setDefault(Locale.US);
		new Thread(new billboard_sk()).start();
	}
	
	StringTokenizer st;
	BufferedReader in;
	PrintWriter out;
	final String FILE = "billboard";
	
	String nextToken() throws IOException {
		while ((st == null) || (!st.hasMoreTokens())) {
			st = new StringTokenizer(in.readLine());
		}
		return st.nextToken();
	}
	
	public void run() {
		try {
			in = new BufferedReader(new FileReader(FILE + ".in"));
			out = new PrintWriter(FILE + ".out");
			solution();
			out.close();
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		}
	}
	
	int nextInt() throws Exception {
		return Integer.parseInt(nextToken());
	}
	
	boolean pIn(int x, int y, int j) {
		return ((x >= x1[j]) && (x <= x2[j])) && ((y >= y1[j]) && (y <= y2[j]));
	}
	
	void remove(int i) {
		if (rm[i]) {
			return;
		}
		
		rm[i] = true;
		k--;
		for (int j : r[i]) {
			remove(j);
		}
	}
	
	int w, h, k, n;
	
	int m;
	List<Integer>[] r;
	
	int[] x1, x2, y1, y2, x, y;
	boolean[] rm;
	
	void solution() throws Exception {
		w = nextInt();
		h = nextInt();
		k = 0;
		m = 0;
		
		n = nextInt();
		
		x1 = new int[n];
		x2 = new int[n];
		y1 = new int[n];
		y2 = new int[n];
		x = new int[n];
		y = new int[n];
		rm = new boolean[n];
		
		r = new List[n];
		for (int i = 0; i < n; i++) {
			r[i] = new ArrayList<Integer>();
		}
		
		for (int i = 0; i < n; i++) {
			int c = nextInt();
			if (c == 1) {
				x1[m] = nextInt();
				y1[m] = nextInt();
				x2[m] = nextInt();
				y2[m] = nextInt();
				x[m] = nextInt();
				y[m] = nextInt();
				
				for (int j = m - 1; j >= 0; j--) {
					if (pIn(x[m], y[m], j)) {
						r[j].add(m);
					}
				}
				
				m++;
				k++;
				
			} else if (c == 2) {
				int k = nextInt() - 1;
				if (k < m) {
					remove(k);
				}
			} else if (c == 3) {
				int k = nextInt() - 1;
				int r = 0;
				if (!rm[k]) {
					for (int j = k; j < m; j++) {
						if (pIn(x[j], y[j], k)) {
							r++;
						}
					}
				}
				out.println(r);
			} else {
				out.println(k);
			}
		}
	}
}