#include <bits/stdc++.h>
using namespace std;
const int P = 1e7 + 19, MOD = 1e9 + 7;
const int MAXN = 5001;
const int MAXQ = 3e4 + 1;
bool query_leaf[1 << 16];
int n, k, q;
int v[MAXQ + MAXN], m[MAXQ + MAXN], lo[MAXQ + MAXN], hi[MAXQ + MAXN];
inline int ADD(int a, int b) {
  a += b;
  while (a < 0) a += MOD;
  return a % MOD;
}
inline int MUL(int a, int b) { return (long long)a * b % MOD; }
class Knapsack {
 private:
  vector<int> best;

 public:
  Knapsack() { best.resize(k + 1); }
  void add(vector<pair<int, int>> &items) {
    int v, m;
    for (auto x : items) {
      tie(v, m) = x;
      for (int j = k; j > 0; --j)
        if (j - m >= 0) best[j] = max(best[j], best[j - m] + v);
    }
  }
  int get_score() {
    int ret = 0, p = 1;
    for (int i = 1; i <= k; ++i) {
      ret = ADD(ret, MUL(p, best[i]));
      p = MUL(p, P);
    }
    return ret;
  }
};
stack<Knapsack> S;
class Tournament {
 private:
  int offset, lo, hi;
  vector<vector<pair<int, int>>> tree;
  void insert(int node, int from, int to, pair<int, int> &item) {
    if (hi <= from || to <= lo) return;
    if (from >= lo && to <= hi) {
      tree[node].push_back(item);
      return;
    }
    insert(2 * node, from, (from + to) / 2, item);
    insert(2 * node + 1, (from + to) / 2, to, item);
  }
  void solve(int node, int from, int to) {
    Knapsack curr = S.top();
    curr.add(tree[node]);
    S.push(curr);
    if (from + 1 == to) {
      if (query_leaf[from]) printf("%d\n", S.top().get_score());
      S.pop();
      return;
    }
    solve(2 * node, from, (from + to) / 2);
    solve(2 * node + 1, (from + to) / 2, to);
    S.pop();
  }

 public:
  Tournament() {}
  void init(int n) {
    for (offset = 1; offset <= n; offset <<= 1)
      ;
    tree.resize(2 * offset);
  }
  void insert(pair<int, int> item, int _lo, int _hi) {
    lo = _lo;
    hi = _hi;
    insert(1, 0, offset, item);
  }
  void dfs() { solve(1, 0, offset); }
};
int main(void) {
  scanf("%d%d", &n, &k);
  for (int i = 0; i < n; ++i) scanf("%d%d", &v[i], &m[i]);
  scanf("%d", &q);
  for (int i = 0; i < q; ++i) {
    int type;
    scanf("%d", &type);
    if (type == 1) {
      scanf("%d%d", &v[n], &m[n]);
      lo[n++] = i;
    }
    if (type == 2) {
      int x;
      scanf("%d", &x);
      --x;
      hi[x] = i + 1;
    }
    if (type == 3) query_leaf[i] = true;
  }
  Tournament T;
  T.init(q);
  for (int i = 0; i < n; ++i) {
    if (hi[i] == 0) hi[i] = q + 1;
    --hi[i];
    if (lo[i] < hi[i]) T.insert({v[i], m[i]}, lo[i], hi[i]);
  }
  S.push(Knapsack());
  T.dfs();
  return 0;
}
