Problem: This is an interactive problem.

Omkar has just come across a duck! The duck is walking on a grid with n rows and n columns (2 ≤ n ≤ 25) so that the grid contains a total of n^2 cells. Let's denote by (x, y) the cell in the x-th row from the top and the y-th column from the left. Right now, the duck is at the cell (1, 1) (the cell in the top left corner) and would like to reach the cell (n, n) (the cell in the bottom right corner) by moving either down 1 cell or to the right 1 cell each second.

Since Omkar thinks ducks are fun, he wants to play a game with you based on the movement of the duck. First, for each cell (x, y) in the grid, you will tell Omkar a nonnegative integer a_{x,y} not exceeding 10^{16}, and Omkar will then put a_{x,y} uninteresting problems in the cell (x, y). After that, the duck will start their journey from (1, 1) to (n, n). For each cell (x, y) that the duck crosses during their journey (including the cells (1, 1) and (n, n)), the duck will eat the a_{x,y} uninteresting problems in that cell. Once the duck has completed their journey, Omkar will measure their mass to determine the total number k of uninteresting problems that the duck ate on their journey, and then tell you k.

Your challenge, given k, is to exactly reproduce the duck's path, i. e. to tell Omkar precisely which cells the duck crossed on their journey. To be sure of your mastery of this game, Omkar will have the duck complete q different journeys (1 ≤ q ≤ 10^3). Note that all journeys are independent: at the beginning of each journey, the cell (x, y) will still contain a_{x,y} uninteresting tasks.

Interaction

The interaction will begin with a line containing a single integer n (2 ≤ n ≤ 25), the amount of rows and columns in the grid. Read it.

Your program should then print n lines. The x-th line should contain n integers a_{x,1}, a_{x,2}, ..., a_{x,n} satisfying 0 ≤ a_{x,y} ≤ 10^{16}, where a_{x,y} is the amount of uninteresting problems Omkar should place in the cell (x, y).

After that, you will first receive a single integer q, the amount of journeys that the duck will take. q queries will follow; each query will consist of a single line containing an integer k, the amount of uninteresting problems that the duck ate on that journey. After each query, given that you have determined that the duck visited the cells (x_1, y_1), (x_2, y_2), ..., (x_{2n - 1}, y_{2n - 1}) in that order (it should always be true that (x_1, y_1) = (1, 1) and (x_{2n - 1}, y_{2n - 1}) = (n, n)), you should output 2n - 1 lines so that the j-th line contains the two integers x_j, y_j.

Bear in mind that if the sum on your path is k, but your path is different from the actual hidden path, then your solution is still wrong!

After printing each line do not forget to output end of line and flush the output. Otherwise, you will get Idleness limit exceeded. To do this, use:

  * fflush(stdout) or cout.flush() in C++;
  * System.out.flush() in Java;
  * flush(output) in Pascal;
  * stdout.flush() in Python;
  * see documentation for other languages.



Hack Format

To hack, first output a line containing n and another line containing q. It must be true that 2 ≤ n ≤ 25 and 1 ≤ q ≤ 1000. Then, output the q journeys taken by the duck in the same format as described above: for each journey, given that the duck visited the cells (x_1, y_1), (x_2, y_2), ..., (x_{2n - 1}, y_{2n - 1}) in that order, you should output 2n - 1 lines so that the j-th line contains the two integers x_j, y_j. It must be true that (x_1, y_1) = (1, 1) and (x_{2n - 1}, y_{2n - 1}) = (n, n). Additionally, for each j such that 2 ≤ j ≤ 2n - 1, it must be true that 1 ≤ x_j, y_j ≤ n and either (x_j, y_j) = (x_{j - 1} + 1, y_{j - 1}) or (x_j, y_j) = (x_{j - 1}, y_{j - 1} + 1).

Example

Input


4




3
23







26







27









Output


1 2 3 6
4 6 2 10
9 0 7 3
2 8 8 2


1 1
1 2
1 3
2 3
2 4
3 4
4 4

1 1
2 1
3 1
3 2
3 3
3 4
4 4

1 1
1 2
1 3
1 4
2 4
3 4
4 4

Note

The duck's three journeys are illustrated below.

1 + 2 + 3 + 2 + 10 + 3 + 2 = 23 

<image>

1 + 4 + 9 + 0 + 7 + 3 + 2 = 26 

<image>

1 + 2 + 3 + 6 + 10 + 3 + 2 = 27 

<image>

Solution (in JAVA):

Solution:
import java.awt.Point;
import java.util.ArrayDeque;

public class Main {

	public static void main(String[] args) {
		new Main();
	}

	public Main() {
		FastScanner fs = new FastScanner();
		java.io.PrintWriter out = new java.io.PrintWriter(System.out);
		solve(fs, out);
		out.flush();
	}

	public void solve(FastScanner fs, java.io.PrintWriter out) {
		int n = fs.nextInt();
		long[][] min = new long[n][n], max = new long[n][n];
		min[0][0] = max[0][0] = 1;
		long[][] a = new long[n][n];
		for (int i = 0;i < n;++ i) {
			a[i][0] = IntMath.powLong(2, i);
			out.print(a[i][0]);
			for (int j = 1;j < n;++ j) {
				out.print(' ');
				a[i][j] = ((j + 1) % 2) * IntMath.powLong(2, i + j);
				out.print(a[i][j]);
			}
			out.println();
		}
		for (int i = 1;i < n;++ i) {
			min[i][0] = min[i - 1][0] + a[i][0];
			max[i][0] = max[i - 1][0] + a[i][0];
			min[0][i] = min[0][i - 1] + a[0][i];
			max[0][i] = max[0][i - 1] + a[0][i];
		}
		for (int i = 1;i < n;++ i) {
			for (int j = 1;j < n;++ j) {
				min[i][j] = Math.min(min[i - 1][j], min[i][j - 1]) + a[i][j];
				max[i][j] = Math.max(max[i - 1][j], max[i][j - 1]) + a[i][j];
			}
		}
		out.flush();
		int q = fs.nextInt();
		ArrayDeque<Point> p = new ArrayDeque<>(2 * n);
		while(q --> 0) {
			long k = fs.nextLong();
			k -= a[n - 1][n - 1];
			p.addLast(new Point(n, n));
			while(k > 0) {
				int x = p.peekLast().x - 1, y = p.peekLast().y - 1;
				if (y == 0) {
					p.addLast(new Point(x, y + 1));
					k -= a[y][x - 1];
				} else if (x == 0) {
					p.addLast(new Point(x + 1, y));
					k -= a[y - 1][x];
				} else if (min[y - 1][x] <= k && k <= max[y - 1][x]) {
					p.addLast(new Point(x + 1, y));
					k -= a[y - 1][x];
				} else {
					p.addLast(new Point(x, y + 1));
					k -= a[y][x - 1];
				}
			}
			while(!p.isEmpty()) {
				Point poll = p.pollLast();
				out.println(poll.y + " " + poll.x);
			}
			out.flush();
		}
	}


	static class FastScanner {
		private final java.io.InputStream in = System.in;
		private final byte[] buffer = new byte[1024];
		private int ptr = 0;
		private int buflen = 0;
		private boolean hasNextByte() {
			if (ptr < buflen) return true;
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (java.io.IOException e) {
				e.printStackTrace();
			}
			return buflen > 0;
		}
		private byte readByte() {
			return hasNextByte() ? buffer[ptr++ ] : -1;
		}
		private static boolean isPrintableChar(byte c) {
			return 32 < c || c < 0;
		}
		private static boolean isNumber(int c) {
			return '0' <= c && c <= '9';
		}
		public boolean hasNext() {
			while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++ ;
			return hasNextByte();
		}
		public String next() {
			if (!hasNext()) throw new java.util.NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			byte b;
			while (isPrintableChar(b = readByte())) sb.appendCodePoint(b);
			return sb.toString();
		}
		public final long nextLong() {
			if (!hasNext()) throw new java.util.NoSuchElementException();
			long n = 0;
			try {
				byte b = readByte();
				if (b == '-') {
					while(isNumber(b = readByte())) n = n * 10 + '0' - b;
					return n;
				} else if (!isNumber(b)) throw new NumberFormatException();
				do n = n * 10 + b - '0'; while (isNumber(b = readByte()));
			} catch (java.util.NoSuchElementException e) {
			}
			return n;
		}
		public final int nextInt() {
			if (!hasNext()) throw new java.util.NoSuchElementException();
			int n = 0;
			try {
				byte b = readByte();
				if (b == '-') {
					while(isNumber(b = readByte())) n = n * 10 + '0' - b;
					return n;
				} else if (!isNumber(b)) throw new NumberFormatException();
				do n = n * 10 + b - '0'; while (isNumber(b = readByte()));
			} catch (java.util.NoSuchElementException e) {
			}
			return n;
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
	}
	public static class Arrays {
		public static void sort(final int[] array) {
			int l, min = 0xFFFFFFFF, max = 0;
			for (l = 0;l < array.length;++ l) {
				int i = array[l];
				min &= i;
				max |= i;
				if ((i & 0x80000000) == 0) break;
			}
			for (int r = l + 1;r < array.length;++ r) {
				int i = array[r];
				min &= i;
				max |= i;
				if ((i & 0x80000000) != 0) {
					array[r] = array[l];
					array[l ++] = i;
				}
			}
			int use = min ^ max, bit = Integer.highestOneBit(use & 0x7FFFFFFF);
			if (bit == 0) return;
			sort(array, 0, l, use, bit);
			sort(array, l, array.length, use, bit);
		}
		private static void sort(final int[] array, final int left, final int right, final int use, int digit) {
			if (right - left <= 96) {
				for (int i = left + 1;i < right;++ i) {
					int tmp = array[i], tmp2, j;
					for (j = i;j > left && (tmp2 = array[j - 1]) > tmp;-- j) array[j] = tmp2;
					array[j] = tmp;
				}
				return;
			}
			int l = left;
			while(l < right && (array[l] & digit) == 0) ++ l;
			for (int r = l + 1;r < right;++ r) {
				int i = array[r];
				if ((i & digit) == 0) {
					array[r] = array[l];
					array[l ++] = i;
				}
			}
			if ((digit = Integer.highestOneBit(use & digit - 1)) == 0) return;
			sort(array, left, l, use, digit);
			sort(array, l, right, use, digit);
		}
		public static void sort(final long[] array) {
			int l;
			long min = 0xFFFFFFFFFFFFFFFFL, max = 0;
			for (l = 0;l < array.length;++ l) {
				long i = array[l];
				min &= i;
				max |= i;
				if ((i & 0x8000000000000000L) == 0) break;
			}
			for (int r = l + 1;r < array.length;++ r) {
				long i = array[r];
				min &= i;
				max |= i;
				if ((i & 0x8000000000000000L) != 0) {
					array[r] = array[l];
					array[l ++] = i;
				}
			}
			long use = min ^ max, bit = Long.highestOneBit(use & 0x7FFFFFFFFFFFFFFFL);
			if (bit == 0) return;
			sort(array, 0, l, use, bit);
			sort(array, l, array.length, use, bit);
		}
		private static void sort(final long[] array, final int left, final int right, final long use, long digit) {
			if (right - left <= 96) {
				for (int i = left + 1, j;i < right;++ i) {
					long tmp = array[i], tmp2;
					for (j = i;j > left && (tmp2 = array[j - 1]) > tmp;-- j) array[j] = tmp2;
					array[j] = tmp;
				}
				return;
			}
			int l = left;
			while(l < right && (array[l] & digit) == 0) ++ l;
			for (int r = l + 1;r < right;++ r) {
				long i = array[r];
				if ((i & digit) == 0) {
					array[r] = array[l];
					array[l ++] = i;
				}
			}
			if ((digit = Long.highestOneBit(use & digit - 1)) == 0) return;
			sort(array, left, l, use, digit);
			sort(array, l, right, use, digit);
		}
	}

	public static class IntMath {
		public static int gcd(int a, int b) {
			while (a != 0) if ((b %= a) != 0) a %= b; else return a;
			return b;
		}
		public static int gcd(int... array) {
			int ret = array[0];
			for (int i = 1;i < array.length;++ i) ret = gcd(ret, array[i]);
			return ret;
		}
		public static long gcd(long a, long b) {
			while (a != 0) if ((b %= a) != 0) a %= b; else return a;
			return b;
		}
		public static long gcd(long... array) {
			long ret = array[0];
			for (int i = 1;i < array.length;++ i) ret = gcd(ret, array[i]);
			return ret;
		}
		public static long lcm(long a, long b) {
			return a / gcd(a, b) * b;
		}
		public static int pow(int a, int b) {
			int ans = 1;
			for (int mul = a;b > 0;b >>= 1, mul *= mul) if ((b & 1) != 0) ans *= mul;
			return ans;
		}
		public static long powLong(long a, long b) {
			long ans = 1;
			for (long mul = a;b > 0;b >>= 1, mul *= mul) if ((b & 1) != 0) ans *= mul;
			return ans;
		}
		public static int pow(int a, int b, int mod) {
			if (b < 0) b = b % (mod - 1) + mod - 1;
			long ans = 1;
			for (long mul = a;b > 0;b >>= 1, mul = mul * mul % mod) if ((b & 1) != 0) ans = ans * mul % mod;
			return (int)ans;
		}
		public static int floorsqrt(long n) {
			return (int)Math.sqrt(n + 0.1);
		}
		public static int ceilsqrt(long n) {
			return n <= 1 ? (int)n : (int)Math.sqrt(n - 0.1) + 1;
		}
	}
}