#include <bits/stdc++.h>
using namespace std;
void printPath(vector<pair<int, int>> &path) {
  for (auto it : path) cout << (it.first + 1) << " " << (it.second + 1) << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  long long arr[n][n];
  memset(arr, 0, sizeof(arr));
  pair<long long, long long> achieve[n][n];
  arr[0][0] = 0;
  achieve[0][0] = {0, 0};
  for (int k = 1; k < 2 * (n - 1); k++) {
    long long prev = 0;
    for (int i = 0; i < n; i++) {
      int j = k - i;
      if (j < 0 || j >= n) continue;
      pair<long long, long long> available = {2000000000000000000, -1};
      if (i) {
        available.first = (available.first < achieve[i - 1][j].first
                               ? available.first
                               : achieve[i - 1][j].first);
        available.second = (available.second > achieve[i - 1][j].second
                                ? available.second
                                : achieve[i - 1][j].second);
      }
      if (j) {
        available.first = (available.first < achieve[i][j - 1].first
                               ? available.first
                               : achieve[i][j - 1].first);
        available.second = (available.second > achieve[i][j - 1].second
                                ? available.second
                                : achieve[i][j - 1].second);
      }
      long long diff = prev - available.first;
      arr[i][j] = diff;
      available.first += diff;
      available.second += diff;
      achieve[i][j] = available;
      prev = available.second + 1;
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) cout << arr[i][j] << " ";
    cout << endl;
  }
  int q;
  cin >> q;
  vector<pair<int, int>> path;
  while (q--) {
    long long x;
    cin >> x;
    int i = n - 1, j = n - 1;
    while (i || j) {
      x -= arr[i][j];
      path.push_back({i, j});
      if (i == 0) {
        j--;
        continue;
      }
      if (j == 0) {
        i--;
        continue;
      }
      if (achieve[i - 1][j].first <= x && x <= achieve[i - 1][j].second)
        i--;
      else
        j--;
    }
    path.push_back({i, j});
    reverse(path.begin(), path.end());
    printPath(path);
    path.clear();
  }
}
