#include <bits/stdc++.h>
using namespace std;
int main() {
  long long N;
  cin >> N;
  vector<vector<long long>> matrix(N, vector<long long>(N));
  for (long long i = 0; i < N; i++) {
    long long b = i;
    long long on = 1;
    for (long long j = 0; j < N; j++) {
      if (on == 1)
        matrix[i][j] = ((long long)1 << b), on = -1;
      else
        on = 1;
      cout << matrix[i][j] << " ";
      b++;
    }
    cout << endl;
  }
  long long Q;
  cin >> Q;
  while (Q--) {
    long long K;
    cin >> K;
    long long i = 0, j = 0;
    cout << 1 << " " << 1 << endl;
    long long b = 0;
    while (i != N - 1 || j != N - 1) {
      b++;
      long long val = K & ((long long)1 << b);
      if (i == N - 1)
        j++;
      else if (j == N - 1)
        i++;
      else if (val == matrix[i][j + 1])
        j++;
      else
        i++;
      cout << i + 1 << " " << j + 1 << endl;
    }
  }
}
