#include <bits/stdc++.h>
using namespace std;
const int P = 1e7 + 19;
const int Q = 1e9 + 7;
int n, m, k;
vector<pair<int, int> > a;
vector<int> cnt;
vector<vector<pair<int, int> > > t;
vector<vector<int> > f;
void insert(int cur, int l, int r, int L, int R, pair<int, int> x) {
  if (R <= l || r <= L) return;
  if (L <= l && r <= R)
    t[cur].push_back(x);
  else {
    insert((cur << 1), l, ((l + r) >> 1), L, R, x);
    insert((cur << 1 | 1), ((l + r) >> 1), r, L, R, x);
  }
}
void solve(int cur, int l, int r, int dep) {
  f[dep] = f[dep - 1];
  for (auto x : t[cur]) {
    for (int i = k; i >= x.second; --i) {
      f[dep][i] = max(f[dep][i], f[dep][i - x.second] + x.first);
    }
  }
  if (l == r - 1) {
    if (!cnt[l]) return;
    int ans = 0;
    for (int i = k; i >= 1; --i) ans = ((long long)ans * P + f[dep][i]) % Q;
    while (cnt[l]--) printf("%d\n", ans);
  } else {
    solve((cur << 1), l, ((l + r) >> 1), dep + 1);
    solve((cur << 1 | 1), ((l + r) >> 1), r, dep + 1);
  }
}
int main() {
  scanf("%d%d", &n, &k);
  a.resize(n);
  for (auto& x : a) scanf("%d%d", &x.first, &x.second);
  scanf("%d", &m);
  vector<int> l(n, 0), r(n, m);
  cnt.resize(m, 0);
  int tim = 0;
  bool flag = false;
  for (int i = 0; i < m; ++i) {
    int opt;
    scanf("%d", &opt);
    if (opt == 1) {
      pair<int, int> x;
      scanf("%d%d", &x.first, &x.second);
      a.push_back(x);
      l.push_back(flag ? tim : (flag = true, ++tim));
      r.push_back(m);
    } else if (opt == 2) {
      int x;
      scanf("%d", &x);
      r[x - 1] = flag ? tim : (flag = true, ++tim);
    } else {
      flag = false;
      ++cnt[tim];
    }
  }
  for (auto& x : r)
    if (x == m) x = tim + 1;
  t.resize((tim + 1) << 2);
  f.resize(20, vector<int>(k + 1, 0));
  for (int i = 0; i < (int)a.size(); ++i)
    insert(1, 0, tim + 1, l[i], r[i], a[i]);
  solve(1, 0, tim + 1, 1);
  return 0;
}
