#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) {
      long long cur = (1ll << (i + j - 2));
      cout << ((i & 1) ? cur : 0);
      if (j < n)
        cout << ' ';
      else {
        cout << endl;
        cout.flush();
      }
    }
  int q;
  cin >> q;
  while (q--) {
    long long val;
    cin >> val;
    cout << "1 1" << endl;
    cout.flush();
    int x = 1, y = 1;
    while (x != n || y != n) {
      if (x & 1) {
        if (val & (1ll << (x + y - 1)))
          y++;
        else
          x++;
      } else {
        if (val & (1ll << (x + y - 1)))
          x++;
        else
          y++;
      }
      cout << x << ' ' << y << endl;
      cout.flush();
    }
  }
  return 0;
}
