Problem: There's a famous museum in the city where Kleofáš lives. In the museum, n exhibits (numbered 1 through n) had been displayed for a long time; the i-th of those exhibits has value vi and mass wi. 

Then, the museum was bought by a large financial group and started to vary the exhibits. At about the same time, Kleofáš... gained interest in the museum, so to say.

You should process q events of three types:

  * type 1 — the museum displays an exhibit with value v and mass w; the exhibit displayed in the i-th event of this type is numbered n + i (see sample explanation for more details)
  * type 2 — the museum removes the exhibit with number x and stores it safely in its vault
  * type 3 — Kleofáš visits the museum and wonders (for no important reason at all, of course): if there was a robbery and exhibits with total mass at most m were stolen, what would their maximum possible total value be?



For each event of type 3, let s(m) be the maximum possible total value of stolen exhibits with total mass  ≤ m.

Formally, let D be the set of numbers of all exhibits that are currently displayed (so initially D = {1, ..., n}). Let P(D) be the set of all subsets of D and let 

<image>

Then, s(m) is defined as 

<image>

Compute s(m) for each <image>. Note that the output follows a special format.

Input

The first line of the input contains two space-separated integers n and k (1 ≤ n ≤ 5000, 1 ≤ k ≤ 1000) — the initial number of exhibits in the museum and the maximum interesting mass of stolen exhibits. 

Then, n lines follow. The i-th of them contains two space-separated positive integers vi and wi (1 ≤ vi ≤ 1 000 000, 1 ≤ wi ≤ 1000) — the value and mass of the i-th exhibit.

The next line contains a single integer q (1 ≤ q ≤ 30 000) — the number of events.

Each of the next q lines contains the description of one event in the following format:

  * 1 v w — an event of type 1, a new exhibit with value v and mass w has been added (1 ≤ v ≤ 1 000 000, 1 ≤ w ≤ 1000)
  * 2 x — an event of type 2, the exhibit with number x has been removed; it's guaranteed that the removed exhibit had been displayed at that time
  * 3 — an event of type 3, Kleofáš visits the museum and asks his question



There will be at most 10 000 events of type 1 and at least one event of type 3.

Output

As the number of values s(m) can get large, output the answers to events of type 3 in a special format.

For each event of type 3, consider the values s(m) computed for the question that Kleofáš asked in this event; print one line containing a single number 

<image>

where p = 107 + 19 and q = 109 + 7.

Print the answers to events of type 3 in the order in which they appear in the input.

Examples

Input

3 10
30 4
60 6
5 1
9
3
1 42 5
1 20 3
3
2 2
2 4
3
1 40 6
3


Output

556674384
168191145
947033915
181541912


Input

3 1000
100 42
100 47
400 15
4
2 2
2 1
2 3
3


Output

0

Note

In the first sample, the numbers of displayed exhibits and values s(1), ..., s(10) for individual events of type 3 are, in order: 

<image> <image> <image> <image>

The values of individual exhibits are v1 = 30, v2 = 60, v3 = 5, v4 = 42, v5 = 20, v6 = 40 and their masses are w1 = 4, w2 = 6, w3 = 1, w4 = 5, w5 = 3, w6 = 6.

In the second sample, the only question is asked after removing all exhibits, so s(m) = 0 for any m.

Solution (in JAVA):

Solution:
import java.io.*;
import java.util.*;

//java.is.awesome

public class R333qEAMuseumRobbery {

	static int n, k, q;
	static U a[];
	static int t[], qA[], qB[];
	static int ans[][];
	static final int mod = (int) 1e9 + 7;
	static final long mod2 = mod * 1L * mod;
	static final int p = (int) 1e7 + 19;
	static int[] pow;
	static final InputReader in = new InputReader(System.in);
	static final PrintWriter w = new PrintWriter(System.out);

	public static void main(String[] args) {

		n = in.nextInt();
		k = in.nextInt();

		a = new U[n];
		for (int i = 0; i < n; i++)
			a[i] = new U(in.nextInt(), in.nextInt());

		q = in.nextInt();

		t = new int[q];
		qA = new int[q];
		qB = new int[q];

		int total = n, time = 0;

		for (int i = 0; i < q; i++) {
			t[i] = in.nextInt();
			if (t[i] == 1) {
				qA[i] = in.nextInt();
				qB[i] = in.nextInt();
				total++;
			} else if (t[i] == 2) {
				qA[i] = in.nextInt();
			} else
				time++;
		}
		
		int from[] = new int[total];
		int to[] = new int[total];
		int val[] = new int[total];
		int mass[] = new int[total];

		for (int i = 0; i < n; i++) {
			val[i] = a[i].v;
			mass[i] = a[i].m;
		}

		Arrays.fill(to, time);

		total = n;
		time = 0;

		for (int i = 0; i < q; i++) {
			if (t[i] == 1) {
				val[total] = qA[i];
				mass[total] = qB[i];
				from[total] = time;
				total++;
			} else if (t[i] == 2) {
				to[qA[i] - 1] = time;
			} else
				time++;
		}
		
		//System.out.println(time + " " + total);
		//System.out.println(Arrays.toString(from));
		//System.out.println(Arrays.toString(to));

		pow = new int[k];
		pow[0] = 1;
		for (int i = 1; i < k; i++)
			pow[i] = (int) ((pow[i - 1] * 1L * p) % mod);

		O root = new O(0, time - 1);

		for (int i = 0; i < total; i++)
			root.add(from[i], to[i] - 1, new U(val[i], mass[i]));

		ans = new int[100][k + 1];
		root.go(1);

		w.close();
	}

	static class O {

		ArrayList<U> list;
		O left, right;
		int from, to;

		O(int s, int e) {
			this.from = s;
			this.to = e;
			list = new ArrayList<U>();
			if (s != e) {
				int m = (s + e) >> 1;
				left = new O(s, m);
				right = new O(m + 1, e);
			}
		}

		void add(int l, int r, U curr) {
			if (r < from || l > to)
				return;
			if (l <= from && to <= r){
				list.add(curr);
				return;
			}
			if (from != to) {
				left.add(l, r, curr);
				right.add(l, r, curr);
			}
		}

		void go(int h) {
			for (int i = 0; i <= k; i++)
				ans[h][i] = ans[h - 1][i];
			for (U u : list) {
				for (int j = k - u.m; j >= 0; j--) {
					int now = ans[h][j] + u.v;
					if (now > ans[h][j + u.m])
						ans[h][j + u.m] = now;
				}
			}
			if (from == to) {
				long answer = 0;
				for (int i = 1; i <= k; i++) {
					answer += ans[h][i] * 1L * pow[i - 1];
					if (answer >= mod2) 
						answer -= mod2;
				}
				w.println(answer % mod);
			}
			else{
				left.go(h + 1);
				right.go(h + 1);
			}
		}
	}

	static class U {
		int v, m;

		U(int v, int m) {
			this.v = v;
			this.m = m;
		}

		public String toString() {
			return "U : " + v + " " + m;
		}
	}

	static class InputReader {

		private InputStream stream;
		private byte[] buf = new byte[8192];
		private int curChar, snumChars;
		private SpaceCharFilter filter;

		public InputReader(InputStream stream) {
			this.stream = stream;
		}

		public int snext() {
			if (snumChars == -1)
				throw new InputMismatchException();
			if (curChar >= snumChars) {
				curChar = 0;
				try {
					snumChars = stream.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (snumChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		public int nextInt() {
			int c = snext();
			while (isSpaceChar(c))
				c = snext();
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = snext();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = snext();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public long nextLong() {
			int c = snext();
			while (isSpaceChar(c))
				c = snext();
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = snext();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = snext();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public int[] nextIntArray(int n) {
			int a[] = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		public String readString() {
			int c = snext();
			while (isSpaceChar(c))
				c = snext();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = snext();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		public boolean isSpaceChar(int c) {
			if (filter != null)
				return filter.isSpaceChar(c);
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		public interface SpaceCharFilter {
			public boolean isSpaceChar(int ch);
		}
	}
}