#include <bits/stdc++.h>
using namespace std;
const int MAXN = 35000 + 10;
const int P = 10000000 + 19, Q = 1000000000 + 7;
vector<int> T[MAXN << 2];
int w[MAXN], v[MAXN];
int st[MAXN], ed[MAXN];
int op[MAXN];
int n, m, q, x;
struct M {
  int dp[5000 + 10];
} now, tt[50];
void up(int k, int l, int r, int ql, int qr, int id) {
  if (ql <= l && r <= qr) {
    T[k].push_back(id);
    return;
  }
  int mid = (l + r) / 2;
  if (ql <= mid) up(k << 1, l, mid, ql, qr, id);
  if (qr > mid) up(k << 1 | 1, mid + 1, r, ql, qr, id);
}
void kn(int id) {
  for (int i = m; i >= w[id]; i--) {
    if (now.dp[i] < now.dp[i - w[id]] + v[id])
      now.dp[i] = now.dp[i - w[id]] + v[id];
  }
}
int res() {
  int ans = 0;
  for (int i = m; i > 0; i--) ans = (1LL * ans * P % Q + now.dp[i]) % Q;
  return ans;
}
void query(int k, int l, int r, int lev) {
  tt[lev] = now;
  for (int i = 0; i < T[k].size(); i++) kn(T[k][i]);
  if (l == r) {
    if (op[l] == 3) printf("%d\n", res());
    return;
  }
  int mid = (l + r) / 2;
  query(k << 1, l, mid, lev + 1);
  query(k << 1 | 1, mid + 1, r, lev + 1);
  now = tt[lev];
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%d%d", v + i, w + i);
  scanf("%d", &q);
  for (int i = 1; i <= n; i++) st[i] = 1, ed[i] = q;
  for (int i = 1; i <= q; i++) {
    scanf("%d", op + i);
    if (op[i] == 1)
      n++, scanf("%d%d", v + n, w + n), st[n] = i, ed[n] = q;
    else if (op[i] == 2)
      scanf("%d", &x), ed[x] = i - 1;
  }
  for (int i = 1; i <= n; i++) {
    int l = st[i], r = ed[i];
    if (r >= l) up(1, 1, q, l, r, i);
  }
  for (int i = 0; i <= m; i++) now.dp[i] = 0;
  query(1, 1, q, 0);
  return 0;
}
