#include <bits/stdc++.h>
using namespace std;
const long long int MOD = 1000000007;
const long long int MAXN = 1000005;
long long int spf[1000009];
void solve(long long int caseNumber) {
  long long int n;
  cin >> n;
  long long int arr[n][n];
  memset(arr, 0, sizeof(arr));
  for (long long int i = 0; i < n; i++) {
    for (long long int j = 0; j < n; j++) {
      long long int s = i + j;
      long long tmp = (1LL << s);
      if (i % 2) arr[i][j] = tmp;
      cout << arr[i][j] << " ";
    }
    cout << endl;
  }
  fflush(stdout);
  long long int q;
  cin >> q;
  while (q--) {
    long long int val;
    cin >> val;
    long long int row = 0, col = 0;
    cout << "1 1\n";
    while (make_pair(row, col) != make_pair(n - 1, n - 1)) {
      if (row == n - 1)
        col++;
      else if (col == n - 1)
        row++;
      else {
        if (arr[row][col + 1]) {
          if (val & arr[row][col + 1])
            col++;
          else
            row++;
        } else {
          assert(arr[row + 1][col]);
          if (val & arr[row + 1][col])
            row++;
          else
            col++;
        }
      }
      cout << row + 1 << " " << col + 1 << endl;
    }
    fflush(stdout);
  }
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int t = 1;
  for (long long int ii = 1; ii <= t; ii++) {
    solve(ii);
  }
  return 0;
}
