#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  long long n, q, k, n2[55], x, y;
  n2[0] = 1;
  for (int i = 1; i <= 52; i++) n2[i] = n2[i - 1] * 2;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      if (j % 2 == 1)
        cout << "0 ";
      else
        cout << n2[i + j - 3] << " ";
    }
    cout << endl;
  }
  cout.flush();
  cin >> q;
  for (int i = 1; i <= q; i++) {
    cin >> k;
    x = 1, y = 1;
    cout << x << " " << y << endl;
    for (int j = 0; j < 2 * n - 2; j++) {
      if (y % 2 == k % 2)
        y++;
      else
        x++;
      k /= 2;
      cout << x << " " << y << endl;
    }
    cout.flush();
  }
  return 0;
}
