#include <bits/stdc++.h>
using namespace std;
long long N, a[26][26], min1[26][26], max1[26][26];
int main() {
  long long i, j;
  cin >> N;
  for (j = N - 2; j >= 0; j--) {
    for (i = 1; i < N; i++) {
      a[i][j] = max1[i - 1][j + 1] - min1[i][j + 1] + 1;
      min1[i][j] = min1[i][j + 1] + a[i][j];
    }
    max1[N - 1][j] = min1[N - 1][j];
    for (i = N - 2; i >= 0; i--) {
      max1[i][j] = max1[i + 1][j] + a[i][j];
    }
  }
  for (i = 0; i < N; i++) {
    for (j = 0; j < N; j++) {
      printf("%lld ", a[i][j]);
    }
    fflush(stdout);
    printf("\n");
  }
  long long Q;
  cin >> Q;
  while (Q--) {
    long long X;
    scanf("%lld", &X);
    long long nowx = 0, nowy = 0;
    while (1) {
      printf("%lld %lld\n", nowx + 1, nowy + 1);
      fflush(stdout);
      if (nowx == N - 1 && nowy == N - 1) break;
      if (nowx <= N - 2 && X >= min1[nowx + 1][nowy]) {
        nowx++;
        X -= a[nowx][nowy];
      } else {
        nowy++;
        X -= a[nowx][nowy];
      }
    }
  }
}
