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.util.*;
import java.io.*;

public class _E {
	long mod = 1000000007;
	long board[][]=new long[25][25];
	void solve() throws IOException, IllegalArgumentException, IllegalAccessException {
		long pow[]=new long[61];
		pow[0]=1;
		for(int i=1;i<61;i++) {
			pow[i]=pow[i-1]*2;
		}
		for(int i=0;i<25;i++) {
			for(int j=0;j<25;j++) {
				if(j%2==0)
					board[i][j]=pow[53-(i+j)];
			}
		}
		int n=in.nextInt();
		for(int i=0;i<n;i++) {
			for(int j=0;j<n;j++) {
				out.print(board[i][j]+" ");
			}
			out.println();
		}
		out.flush();
		int q=in.nextInt();
		for(int i=0;i<q;i++) {
			long k=in.nextLong();
			int nowr=0;
			int nowc=0;
			k-=board[nowr][nowc];
			out.println("1 1");
			while(nowr!=n-1 || nowc!=n-1) {
				if(board[nowr][nowc]!=0) {
					if(k>=pow[52-(nowr+nowc)]) {
						k-=pow[52-(nowr+nowc)];
						nowr++;
					}
					else {
						nowc++;
					}
				}
				else {
					if(k>=pow[52-(nowr+nowc)]) {
						k-=pow[52-(nowr+nowc)];
						nowc++;
					}
					else {
						nowr++;
					}
				}
				out.println((nowr+1)+" "+(nowc+1));
				out.flush();
			}
		}
	}

	public static void main(String[] args) throws IOException, IllegalArgumentException, IllegalAccessException {
		new _E();
	}

	Debug db;
	InputReader in;
	PrintWriter out;
	StringTokenizer st;

	_E() throws IOException, IllegalArgumentException, IllegalAccessException {
		in = new InputReader(System.in);
		out = new PrintWriter(System.out);
		db = new Debug(System.getSecurityManager() == null);
		solve();
		out.close();
	}
	
	void rte(boolean cond) {
		if(cond) {
			int arr[]=new int[9];
			int x=arr[9];
		}
	}

	class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

		public String next() throws IOException {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				tokenizer = new StringTokenizer(reader.readLine());
			}
			return tokenizer.nextToken();
		}

		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		public int[] nextIntArr(int n) throws NumberFormatException, IOException {
			int arr[] = new int[n];
			for (int i = 0; i < n; i++) {
				arr[i] = this.nextInt();
			}
			return arr;
		}

		public long[] nextLongArr(int n) throws NumberFormatException, IOException {
			long arr[] = new long[n];
			for (int i = 0; i < n; i++) {
				arr[i] = this.nextLong();
			}
			return arr;
		}
	}

	class Pair implements Comparable<Pair> {
		public int x;
		public int y;

		Pair(int a, int b) {
			x = a;
			y = b;
		}

		@Override
		public int compareTo(Pair arg0) {
			if (arg0.x != x)
				return x - arg0.x;
			return y - arg0.y;
		}

		@Override
		public String toString() {
			return "(" + x + ',' + y + ')';
		}
	}

	class Triple implements Comparable<Triple> {
		public int x;
		public int y;
		public int z;

		Triple(int a, int b, int c) {
			x = a;
			y = b;
			z = c;
		}

		@Override
		public int compareTo(Triple arg0) {
			if (arg0.x != x)
				return x - arg0.x;
			return y - arg0.y;
		}

		@Override
		public String toString() {
			return "(" + x + ',' + y + ',' + z + ')';
		}
	}

	class Debug {
		private boolean allowDebug;

		public Debug(boolean allowDebug) {
			this.allowDebug = allowDebug;
		}

		private void outputName(String name) {
			System.out.print(name + " = ");
		}

		public void debug(String name, Object... x) throws IllegalArgumentException, IllegalAccessException {
			outputName(name);
			debug2(name, x);
			if (x.length == 1)
				System.out.println();
		}

		public void debug2(String name, Object... x) throws IllegalArgumentException, IllegalAccessException {
			if (!allowDebug) {
				return;
			}
			if (x.length == 1) {
				Object y = x[0];
				if (y instanceof Collection<?>) {
					ts((Iterable<Object>) y);
				} else if (y.getClass().isArray()) {
					if(y instanceof int[]) {
						System.out.print(Arrays.toString((int[]) y));
					}else if(y instanceof long[]) {
						System.out.print(Arrays.toString((long[]) y));
					}else if(y instanceof char[]) {
						System.out.print(Arrays.toString((char[]) y));
					}else if(y instanceof double[]) {
						System.out.print(Arrays.toString((double[]) y));
					}else if(y instanceof boolean[]) {
						System.out.print(Arrays.toString((boolean[]) y));
					}
					try {
//						return ts((Object[]) y);
					}catch(ClassCastException e1) {
//						return y.toString();
					}
				} else {
					System.out.print(y);
				}
			} else {
				System.out.print("[");
				for (int i = 0; i < x.length; i++) {
					if(i!=0)System.out.print(", ");
					this.debug2(name, x[i]);
				}
				System.out.println("]");
			}

		}

		void ts(Iterable<Object> iter) throws IllegalArgumentException, IllegalAccessException {
//			System.out.println("ITERABLE");
			System.out.print("[");
			boolean first = true;
			for (Object t : iter) {
				if (!first) {
					System.out.print(",");
				}
				first = false;
				debug2("name", t);
			}
			System.out.print("]");
		}
		
		void tmp(Object[] y) throws IllegalArgumentException, IllegalAccessException {
			System.out.print("[");
			boolean first = true;
			for (Object t : y) {
				if (!first) {
					System.out.print(",");
				}
				first = false;
				debug2("name", t);
			}
			System.out.print("]");
		}
	}
}