#include <bits/stdc++.h>
using namespace std;
int M, N, Q;
long long a[30][30], k;
void solve() {
  int x = 1;
  int y = 1;
  long long pw = 1;
  cout << x << " " << y << endl;
  cout.flush();
  for (int i = 1; i <= 2 * N - 2; ++i) {
    long long val = (k & pw);
    if (a[x][y + 1] == val)
      ++y;
    else
      ++x;
    pw *= 2LL;
    cout << x << " " << y << endl;
    cout.flush();
  }
}
int main() {
  cin >> N;
  for (int i = 0; i < N; ++i) {
    a[i + 1][N + 1] = a[N + 1][i] = -1;
    for (int j = 0; j < N; ++j) {
      if (i % 2 == 1) {
        a[i + 1][j + 1] = (1LL << (i + j - 1));
      }
      cout << a[i + 1][j + 1] << " ";
    }
    cout << endl;
    cout.flush();
  }
  cin >> Q;
  for (int i = 0; i < Q; ++i) {
    cin >> k;
    solve();
  }
  return 0;
}
