#include <bits/stdc++.h>
using namespace std;
const long long maxn = 30;
long long n, q;
long long b[maxn][maxn];
long long now[2];
void in();
void solve();
void make();
void send();
int main() {
  ios::sync_with_stdio(false);
  cout.tie(0);
  cin.tie(0);
  in();
  solve();
}
void in() { cin >> n; }
void solve() {
  make();
  send();
  cin >> q;
  for (long long i = 0; i < q; i++) {
    long long X = 0;
    cin >> X;
    cout << "1 1\n";
    now[0] = 1;
    now[1] = 1;
    for (long long k = n * 2 - 3; k >= 0; k--) {
      if ((1ll << k) & X)
        now[1]++;
      else
        now[0]++;
      cout << now[0] << ' ' << now[1] << '\n';
    }
    cout.flush();
  }
}
void send() {
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < n; j++) cout << b[i][j] << ' ';
    cout << '\n';
  }
  cout.flush();
}
void make() {
  long long X = (1ll << n - 1) - 1;
  b[n - 1][n - 1] = X;
  for (long long i = n - 2; i >= 0; i--) {
    for (long long j = 1; j < n; j++) {
      long long X = 0;
      long long Y = 0;
      for (long long k = 0; k < j; k++) X += 1ll << (n * 2 - 3 - k - i);
      for (long long k = j; k < n - 1; k++) X += 1ll << (n - 2 - k);
      Y = X;
      Y -= 1ll << (n * 2 - 2 - j - i);
      Y += 1ll << (n * 2 - 3 - j - i);
      b[i][j] = X - Y + b[i + 1][j - 1];
    }
  }
}
