#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin >> n;
  vector<vector<long long> > mat(n, vector<long long>(n, 0));
  for (int x = 1; x < n; x++) {
    long long num = (1LL) << (x - 1);
    for (int i = x - 1, j = 1; i >= 0 && j < n; i -= 2, j += 2) {
      mat[i][j] = num;
    }
  }
  for (int y = 1; y < n; y++) {
    long long num = (1LL) << (y + n - 2);
    for (int i = n - 1, j = y; i >= 0 && j < n; i--, j++) {
      if (j & 1) {
        mat[i][j] = num;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      cout << mat[i][j] << " ";
    }
    cout << "\n";
    cout.flush();
  }
  int q;
  cin >> q;
  while (q--) {
    long long sum;
    cin >> sum;
    long long x = 0, y = 0;
    cout << "1 1\n";
    cout.flush();
    for (long long i = 0; i < 2 * n - 2; i++) {
      bool st = false;
      long long mask = (1LL << i);
      if (sum & mask) st = true;
      if (x < n - 1) {
        bool st1 = false;
        if (mask & mat[x + 1][y]) st1 = true;
        if (st == st1)
          x++;
        else
          y++;
      } else {
        y++;
      }
      cout << x + 1 << " " << y + 1 << "\n";
      cout.flush();
    }
  }
  return 0;
}
