#include <bits/stdc++.h>
const int MAXN = 15010;
const int MAXK = 1010;
const int MAXQ = 30010;
const int modP = 1e7 + 19;
const int modQ = 1e9 + 7;
using namespace std;
int N, K, Q, cnt;
int W[MAXN], V[MAXN];
vector<int> tree[MAXQ * 4];
map<int, int> mp;
vector<int> queries;
long long pot[MAXK], ans[MAXQ];
long long dp[MAXN][MAXK];
int m(int l, int r) { return (l + r) >> 1; }
void upd(int pos, int l, int r, int beg, int en, int x) {
  if (l > en || r < beg) return;
  if (l >= beg && r <= en) return (void)(tree[pos].push_back(x));
  upd((pos << 1), l, m(l, r), beg, en, x);
  upd((pos << 1) | 1, m(l, r) + 1, r, beg, en, x);
}
void run(int pos, int l, int r, int last) {
  ("Run %d %d %d %d\n", pos, l, r, last);
  for (auto idx : tree[pos]) {
    ("With item %d %d %d\n", idx, V[idx], W[idx]);
    last++;
    int v = V[idx], w = W[idx];
    for (int i = 1; i <= K; i++) {
      dp[last][i] = dp[last - 1][i];
      if (i - w >= 0)
        dp[last][i] = max(dp[last - 1][i], dp[last - 1][i - w] + v);
    }
  }
  for (int i = 1; i <= K; i++) ("%lld ", dp[last][i]);
  ("\n\n");
  if (l == r) {
    long long mx = -1;
    for (int i = 1; i <= K; i++) {
      mx = max(mx, dp[last][i]);
      ans[l] = (ans[l] + (pot[i - 1] * mx) % modQ) % modQ;
    }
    return;
  }
  run(pos << 1, l, m(l, r), last);
  run((pos << 1) | 1, m(l, r) + 1, r, last);
}
int main() {
  scanf("%d%d", &N, &K);
  for (int i = 1; i <= N; i++) {
    scanf("%d%d", &V[i], &W[i]);
    mp.insert(make_pair(i, 1));
  }
  scanf("%d", &Q);
  cnt = 1 + N;
  for (int i = 1; i <= Q; i++) {
    int type, x;
    scanf("%d", &type);
    if (type == 1) {
      scanf("%d%d", &V[cnt], &W[cnt]);
      mp.insert(make_pair(cnt, i));
      cnt++;
    }
    if (type == 2) {
      scanf("%d", &x);
      upd(1, 1, Q, mp[x], i, x);
      mp.erase(mp.find(x));
    } else if (type == 3)
      queries.push_back(i);
  }
  for (auto p : mp) upd(1, 1, Q, p.second, Q, p.first);
  pot[0] = 1LL;
  for (int i = 1; i <= K; i++) pot[i] = (pot[i - 1] * modP) % modQ;
  run(1, 1, Q, 0);
  for (int i : queries) printf("%lld\n", ans[i]);
}
