#include <bits/stdc++.h>
using namespace std;
template <typename T>
void read(T& x) {
  static char c;
  static int f;
  for (c = getchar(), f = 1; c < '0' || c > '9'; c = getchar())
    if (c == '-') f = -f;
  for (x = 0; c >= '0' && c <= '9'; c = getchar()) x = x * 10 + (c & 15);
  x *= f;
}
template <typename T>
void write(T x) {
  static char q[65];
  int cnt = 0;
  if (x < 0) putchar('-'), x = -x;
  q[++cnt] = x % 10, x /= 10;
  while (x) q[++cnt] = x % 10, x /= 10;
  while (cnt) putchar(q[cnt--] + '0');
}
long long L[35][35], R[35][35], val[35][35];
int main() {
  int n;
  read(n);
  for (int i = 1; i <= n; ++i) {
    val[i][n] = 0;
    L[i][n] = R[i][n] = 0;
  }
  for (int j = n - 1; j >= 1; --j) {
    val[n][j] = 0;
    L[n][j] = R[n][j] = L[n][j + 1];
    for (int i = n - 1; i >= 1; --i) {
      val[i][j] = 0;
      if (L[i + 1][j] <= R[i][j + 1]) {
        long long delta = R[i][j + 1] - L[i + 1][j] + 1;
        L[i + 1][j] += delta, R[i + 1][j] += delta;
        val[i + 1][j] += delta;
      }
      L[i][j] = L[i][j + 1];
      R[i][j] = R[i + 1][j];
    }
  }
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= n; putchar(" \n"[j == n]), ++j) write(val[i][j]);
  fflush(stdout);
  int q;
  read(q);
  while (q--) {
    long long x;
    read(x);
    int nx = 1, ny = 1;
    while (nx <= n && ny <= n) {
      write(nx), putchar(' '), write(ny), putchar('\n');
      if (nx < n && L[nx + 1][ny] <= x && x <= R[nx + 1][ny]) {
        x -= val[nx + 1][ny];
        ++nx;
      } else {
        x -= val[nx][ny + 1];
        ++ny;
      }
    }
    fflush(stdout);
  }
  return 0;
}
