//  Задача "" 
//  индивидуальная Интернет-олимпиада сезона 2009-2010.
//  Автор задачи -  , @
//  Автор решения - Нияз Нигматуллин, nigmatullin@rain.ifmo.ru
//

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

public class billboard_nn implements Runnable {
    public static void main(String[] args) {
        new billboard_nn().run();
    }

    class FastScanner {
        BufferedReader br;
        StringTokenizer st;
        boolean eof;
        String buf;

        public FastScanner(String fileName) throws FileNotFoundException {
            br = new BufferedReader(new FileReader(fileName));
            nextToken();
        }

        public FastScanner(InputStream stream) {
            br = new BufferedReader(new InputStreamReader(stream));
            nextToken();
        }

        String nextToken() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (Exception e) {
                    eof = true;
                    break;
                }
            }
            String ret = buf;
            buf = eof ? "-1" : st.nextToken();
            return ret;
        }

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

        long nextLong() {
            return Long.parseLong(nextToken());
        }

        double nextDouble() {
            return Double.parseDouble(nextToken());
        }

        void close() {
            try {
                br.close();
            } catch (Exception e) {

            }
        }

        boolean isEOF() {
            return eof;
        }
    }

    FastScanner sc;
    PrintWriter out;

    private static final String FN = "billboard";

    public void run() {
        Locale.setDefault(Locale.US);
        try {
            sc = new FastScanner(FN + ".in");
            out = new PrintWriter(FN + ".out");
            solve();
            sc.close();
            out.close();
        } catch (Throwable e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

    void doAssert(boolean isRight, String s) {
        if (!isRight)
            throw new AssertionError(s);
    }

    class Item {
        boolean isOnTheGround;
        ArrayList<Item> edges;
        int numberOfLeftEdges;

        public Item() {
            edges = new ArrayList<Item>();
        }

        void add(Item i) {
            edges.add(i);
            ++numberOfLeftEdges;
        }
    }

    class Paper extends Item {
        int x1, y1, x2, y2;

        public Paper(int x1, int y1, int x2, int y2) {
            super();
            this.x1 = x1;
            this.y1 = y1;
            this.x2 = x2;
            this.y2 = y2;
        }

        boolean contains(Nail nail) {
            return x1 <= nail.x && nail.x <= x2 && y1 <= nail.y && nail.y <= y2;
        }

    }

    class Nail extends Item {
        int x, y;

        public Nail(int x, int y) {
            super();
            this.x = x;
            this.y = y;
        }

    }

    void addPaper(int x1, int y1, int x2, int y2) {
        Paper newPaper = new Paper(x1, y1, x2, y2);     
        papers.add(newPaper);
        ++numOfPapers;
    }

    void addNail(int x, int y) {
        Nail newNail = new Nail(x, y);
        for (Paper paper : papers) {
            if (paper.isOnTheGround) {
                continue;
            }
            if (paper.contains(newNail)) {
                newNail.add(paper);
                paper.add(newNail);

            }
        }
        nails.add(newNail);
    }

    int cntPapers() {
        return numOfPapers;
    }

    void removePaper(int k) {
        papers.get(k).isOnTheGround = true;
        papers.get(k).numberOfLeftEdges = 0;
        for (Item nail : papers.get(k).edges) {
            if (nail.isOnTheGround) {
                continue;
            }
            for (Item g : nail.edges) {
                if (g.isOnTheGround) {
                    continue;
                }
                --g.numberOfLeftEdges;
                if (g.numberOfLeftEdges == 0) {
                    g.isOnTheGround = true;
                    --numOfPapers;
                }
            }
            nail.isOnTheGround = true;
        }
        --numOfPapers;
    }

    int cntNailsOnPaper(int k) {
        return papers.get(k).numberOfLeftEdges;
    }

    int numOfPapers, curVersion;
    ArrayList<Paper> papers;
    ArrayList<Nail> nails;

    private void solve() {
        int w = sc.nextInt();
        int h = sc.nextInt();
        int n = sc.nextInt();
        numOfPapers = 0;
        {
            papers = new ArrayList<Paper>();
            nails = new ArrayList<Nail>();
        }
        for (int i = 0; i < n; i++) {
            int type = sc.nextInt();
            if (type == 1) {
                int x1 = sc.nextInt();
                int y1 = sc.nextInt();
                int x2 = sc.nextInt();
                int y2 = sc.nextInt();
                int x = sc.nextInt();
                int y = sc.nextInt();
                doAssert(0 <= x1 && 0 <= y1 && 0 <= x2 && 0 <= y2 && 0 <= x
                        && 0 <= y && x1 <= w && x2 <= w && x <= w && y1 <= h
                        && y2 <= h && y <= h,
                        "coordinates are not on the board, line #" + (i + 1));
                addPaper(x1, y1, x2, y2);
                addNail(x, y);
            } else if (type == 2) {
                int k = sc.nextInt() - 1;
                doAssert(0 <= k && k < papers.size(), "query is bad, line #"
                        + (i + 1));
                removePaper(k);
            } else if (type == 3) {
                int k = sc.nextInt() - 1;
                doAssert(0 <= k && k < papers.size(), "query is bad, line #"
                        + (i + 1));
                out.println(cntNailsOnPaper(k));
            } else if (type == 4) {
                out.println(cntPapers());
            } else {
                doAssert(false, "type of query is bad, line #" + (i + 1));
            }
        }
    }
}
