#include <bits/stdc++.h>
using namespace std;
const int MN = 30111;
const long long MOD = 1e9 + 7;
const long long P = 1e7 + 19;
struct Obj {
  int w, v, from, to;
} a[MN];
int res[MN];
long long f[22][MN], p[MN];
vector<int> it[MN * 4];
int nQuery, nObj, k;
void init(int i, int l, int r) {
  it[i].clear();
  if (l == r) return;
  int mid = (l + r) >> 1;
  init(i << 1, l, mid);
  init(i << 1 | 1, mid + 1, r);
}
void add(int i, int l, int r, int x, int u, int v) {
  if (v < l || r < u) return;
  if (u <= l && r <= v) {
    it[i].push_back(x);
    return;
  }
  int mid = (l + r) >> 1;
  add(i << 1, l, mid, x, u, v);
  add(i << 1 | 1, mid + 1, r, x, u, v);
}
void go(int i, int l, int r, int h) {
  for (int i = (0), _b = (k); i <= _b; ++i) f[h][i] = f[h - 1][i];
  for (int x : it[i]) {
    int w = a[x].w;
    int v = a[x].v;
    for (int sumw = (k), _b = (w); sumw >= _b; --sumw)
      f[h][sumw] = max(f[h][sumw], f[h][sumw - w] + v);
  }
  if (l == r) {
    res[l] = 0;
    for (int m = (1), _b = (k); m <= _b; ++m)
      res[l] = (res[l] + f[h][m] * p[m - 1]) % MOD;
    return;
  }
  int mid = (l + r) >> 1;
  go(i << 1, l, mid, h + 1);
  go(i << 1 | 1, mid + 1, r, h + 1);
}
int main() {
  int n, q;
  p[0] = 1;
  for (int i = (1), _b = (MN - 1); i <= _b; ++i) p[i] = p[i - 1] * P % MOD;
  while (scanf("%d%d", &n, &k) == 2) {
    nObj = 0;
    for (int i = (1), _b = (n); i <= _b; ++i) {
      int v, w;
      scanf("%d%d", &v, &w);
      ++nObj;
      a[nObj].w = w;
      a[nObj].v = v;
      a[nObj].from = 1;
      a[nObj].to = -1;
    }
    nQuery = 0;
    scanf("%d", &q);
    for (int i = (1), _b = (q); i <= _b; ++i) {
      int typ;
      scanf("%d", &typ);
      if (typ == 1) {
        ++nObj;
        scanf("%d%d", &a[nObj].v, &a[nObj].w);
        a[nObj].from = nQuery + 1;
        a[nObj].to = -1;
      } else if (typ == 2) {
        int x;
        scanf("%d", &x);
        a[x].to = nQuery;
      } else {
        ++nQuery;
      }
    }
    for (int i = (1), _b = (nObj); i <= _b; ++i)
      if (a[i].to < 0) a[i].to = nQuery;
    init(1, 1, nQuery);
    for (int i = (1), _b = (nObj); i <= _b; ++i) {
      add(1, 1, nQuery, i, a[i].from, a[i].to);
    }
    go(1, 1, nQuery, 1);
    for (int i = (1), _b = (nQuery); i <= _b; ++i) printf("%d\n", (int)res[i]);
    puts("");
  }
}
