#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, q;
  cin >> n >> m >> q;
  int p[n], sq[m];
  int juq[m][n];
  for (int i = 0; i < n; i++) {
    p[i] = 0;
  }
  for (int i = 0; i < m; i++) {
    sq[i] = n;
  }
  int x[q], num[q], que[q];
  for (int i = 0; i < q; i++) {
    cin >> x[i];
    if (x[i] == 1) {
      cin >> num[i];
      num[i]--;
    } else if (x[i] == 2) {
      cin >> num[i] >> que[i];
      num[i]--;
      que[i]--;
    }
  }
  for (int i = 0; i < q; i++) {
    if (x[i] == 1) {
      cout << p[num[i]] << endl;
    } else {
      p[num[i]] += sq[que[i]];
      juq[que[i]][num[i]] = 1;
      sq[que[i]] -= 1;
      for (int j = 0; j < n; j++) {
        if (juq[que[i]][j]) {
          p[j] -= 1;
        }
      }
    }
  }
  return 0;
}
