#include <bits/stdc++.h>
using namespace std;
const int N = 30030, M = 5005000, L = 1010, oo = 1000000000, P = 10000019,
          Q = 1000000007;
int i, j, k, n, m, nm, Tn, q, En, ch, last, o, x, An;
int f[22][L], h[N << 2], ans[N], p[N];
struct cc {
  int l, r, v, w;
} A[N];
struct edge {
  int s, n;
} E[M];
void R(int &x) {
  x = 0;
  ch = getchar();
  while (ch < '0' || '9' < ch) ch = getchar();
  while ('0' <= ch && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
}
int max(const int &x, const int &y) {
  if (x > y) return x;
  return y;
}
void E_add(int x, int y) {
  E[++En].s = y;
  E[En].n = h[x];
  h[x] = En;
}
void T_add(int L, int R, int l, int r, int x, int k) {
  if (L == l && R == r) {
    E_add(k, x);
    return;
  }
  int mid = (L + R) >> 1;
  if (r <= mid)
    T_add(L, mid, l, r, x, k << 1);
  else {
    if (l > mid)
      T_add(mid + 1, R, l, r, x, k << 1 | 1);
    else
      T_add(L, mid, l, mid, x, k << 1),
          T_add(mid + 1, R, mid + 1, r, x, k << 1 | 1);
  }
}
void T_bl(int L, int R, int dp, int k) {
  for (int i = 0; i <= m; i++) f[dp][i] = f[dp - 1][i];
  for (int kk = h[k]; kk; kk = E[kk].n) {
    int v = A[E[kk].s].v, w = A[E[kk].s].w;
    for (int i = m; i >= w; i--) f[dp][i] = max(f[dp][i], f[dp][i - w] + v);
  }
  if (L == R) {
    int &res = ans[L];
    int pp = 1;
    for (int i = 1; i <= m; i++) {
      res = ((long long)f[dp][i] * pp + res) % Q;
      pp = (long long)pp * P % Q;
    }
    return;
  }
  int mid = (L + R) >> 1;
  T_bl(L, mid, dp + 1, k << 1);
  T_bl(mid + 1, R, dp + 1, k << 1 | 1);
}
int main() {
  R(n);
  R(m);
  for (i = 1; i <= n; i++) {
    A[i].l = 1;
    A[i].r = oo;
    R(A[i].v);
    R(A[i].w);
  }
  R(q);
  An = n;
  for (i = 1; i <= q; i++) {
    last = o;
    R(o);
    if (o == 3) {
      if (last == 3)
        p[++nm] = Tn;
      else
        p[++nm] = ++Tn;
      continue;
    }
    if (o == 1) {
      An++;
      A[An].l = Tn + 1;
      A[An].r = oo;
      R(A[An].v);
      R(A[An].w);
      continue;
    }
    if (o == 2) {
      R(x);
      A[x].r = Tn;
      continue;
    }
  }
  for (i = 1; i <= An; i++) {
    if (A[i].r == oo) A[i].r = Tn;
    if (1 <= A[i].l && A[i].l <= A[i].r && A[i].r <= Tn)
      T_add(1, Tn, A[i].l, A[i].r, i, 1);
  }
  T_bl(1, Tn, 1, 1);
  for (i = 1; i <= nm; i++) printf("%d\n", ans[p[i]]);
}
