#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 10;
const long long int LINF = 1LL * INF * INF;
const int MAXN = 2e5 + 10;
const int MAXM = 5e3 + 10;
priority_queue<int> pq;
vector<vector<int> > graph;
queue<int> que;
long long int A[30][30];
int main() {
  long long int n, m, k, a, b, x, y, q;
  int sum = 0;
  int cnt = 0;
  int mx = 0;
  int mn = INF;
  int cur = 0, idx = -1;
  int tc;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      cur = (i + j) - 2;
      if (i & 1) A[i][j] = (1LL << cur);
      cout << A[i][j] << " ";
      fflush(stdout);
    }
    cout << "\n";
    fflush(stdout);
  }
  for (int i = 1; i <= n; i++) {
    A[i][n + 1] = -INF;
  }
  for (int i = 1; i <= n; i++) {
    A[n + 1][i] = -INF;
  }
  cin >> q;
  long long int vv;
  for (int i = 0; i < q; i++) {
    cin >> k;
    vector<pair<int, int> > ans;
    x = 1;
    y = 1;
    ans.push_back(pair<int, int>(x, y));
    for (int i = 1; i <= (n << 1) - 2; i++) {
      vv = (1LL << i) & k;
      if (vv == A[x + 1][y]) {
        x++;
      } else {
        y++;
      }
      ans.push_back(pair<int, int>(x, y));
    }
    for (int i = 0; i < (int)ans.size(); i++) {
      cout << ans[i].first << " " << ans[i].second << "\n";
      fflush(stdout);
    }
  }
  return 0;
}
