#include <bits/stdc++.h>
using namespace std;
int n, k, q;
int cnt;
const int N = 50000;
const int P = 20;
int vi[N], wi[N], ti[N], tj[N];
int lb[N], rb[N], lc[N], rc[N], tot;
vector<int> V[N];
int build(int l, int r) {
  int t = ++tot;
  lb[t] = l;
  rb[t] = r;
  if (l < r) {
    lc[t] = build(l, (l + r) / 2);
    rc[t] = build((l + r) / 2 + 1, r);
  }
  return t;
}
void modify(int t, int l, int r, int k) {
  if (l > r) return;
  if (l <= lb[t] && rb[t] <= r) {
    V[t].push_back(k);
    return;
  }
  if (l <= rb[lc[t]]) modify(lc[t], l, r, k);
  if (r >= lb[rc[t]]) modify(rc[t], l, r, k);
}
int top;
int F[P][N];
void dfs(int t) {
  top++;
  for (int i = 1; i <= k; ++i) F[top][i] = F[top - 1][i];
  for (int i = 0; i < V[t].size(); ++i)
    for (int j = k - wi[V[t][i]]; j >= 0; --j)
      F[top][j + wi[V[t][i]]] =
          max(F[top][j + wi[V[t][i]]], F[top][j] + vi[V[t][i]]);
  if (lb[t] == rb[t]) {
    int p = 1e7 + 19, q = 1e9 + 7;
    int tmp1 = 1, res = 0;
    for (int i = 1; i <= k; ++i) {
      res = (1ll * tmp1 * F[top][i] + res) % q;
      tmp1 = 1ll * tmp1 * p % q;
    }
    cout << res << endl;
  } else {
    dfs(lc[t]);
    dfs(rc[t]);
  }
  top--;
}
int main() {
  cin >> n >> k;
  for (int i = 1; i <= n; ++i) cin >> vi[i] >> wi[i], ti[i] = 1, tj[i] = -1;
  cin >> q;
  for (int i = 1; i <= q; ++i) {
    int opt, p;
    cin >> opt;
    if (opt == 1)
      n++, cin >> vi[n] >> wi[n], ti[n] = cnt + 1, tj[n] = -1;
    else if (opt == 2)
      cin >> p, tj[p] = cnt;
    else
      cnt++;
  }
  for (int i = 1; i <= n; ++i)
    if (tj[i] == -1) tj[i] = cnt;
  build(1, cnt);
  for (int i = 1; i <= n; ++i) modify(1, ti[i], tj[i], i);
  dfs(1);
}
