#include <bits/stdc++.h>
using namespace std;
void solve();
mt19937 rng(time(0));
long long qpow(long long x, long long p, long long MOD) {
  long long res = 1, v = x;
  while (p) {
    if (p & 1) {
      res *= v;
      res %= MOD;
    }
    v *= v;
    v %= MOD;
    p >>= 1;
  }
  return res;
}
long long inv(long long x, long long MOD) { return qpow(x, MOD - 2, MOD); }
void init() {}
long long read() {
  int ch = getchar();
  if (ch == EOF) {
    return INT_MIN;
  }
  while (!isdigit(ch) && ch != '-') {
    ch = getchar();
    if (ch == EOF) {
      return INT_MIN;
    }
  }
  long long res = 0, sign = 1;
  if (ch == '-') {
    ch = getchar();
    sign = -1;
  }
  while (isdigit(ch)) {
    res = res * 10 + ch - '0';
    ch = getchar();
  }
  return res * sign;
}
int main() {
  init();
  solve();
  return 0;
}
void solve() {
  long long n = read();
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      if (i & 1) {
        printf("%I64d ", 1LL << (i + j));
      } else {
        printf("0 ");
      }
    }
    printf("\n");
  }
  fflush(stdout);
  int q = read();
  while (q--) {
    long long k = read();
    k >>= 1;
    int x = 0, y = 0;
    puts("1 1");
    for (int p = 1; p + 1 < 2 * n; ++p) {
      if ((x & 1LL) == (k & 1LL)) {
        y += 1;
      } else {
        x += 1;
      }
      k >>= 1;
      printf("%d %d\n", x + 1, y + 1);
    }
    fflush(stdout);
  }
}
