#include <bits/stdc++.h>
using namespace std;
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline void dump(T& v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    cout << (*i) << ((i == --v.end()) ? '\n' : ' ');
  }
}
inline string getline() {
  string s;
  getline(cin, s);
  return s;
}
inline void yn(const bool b) {
  b ? cout << ("yes") << '\n' : cout << ("no") << '\n';
}
inline void Yn(const bool b) {
  b ? cout << ("Yes") << '\n' : cout << ("No") << '\n';
}
inline void YN(const bool b) {
  b ? cout << ("YES") << '\n' : cout << ("NO") << '\n';
}
struct io {
  io() {
    ios::sync_with_stdio(false);
    cin.tie(0);
  }
};
const int INF = INT_MAX;
constexpr long long int LLINF = 1LL << 60;
constexpr long long int MOD = 1000000007;
constexpr long double EPS = 1e-11;
int main() {
  long long int n;
  cin >> n;
  vector<vector<long long int> > v(n, vector<long long int>(n));
  for (long long int i = 0; i < (n); ++i) {
    if (i % 2) continue;
    for (long long int j = 0; j < (n); ++j) {
      if (i == 0 && j == 0) continue;
      v[i][j] = 1LL << (i + j - 1);
    }
  }
  for (long long int i = 0; i < (n); ++i) dump(v[i]);
  long long int Q, num;
  cin >> Q;
  while (Q--) {
    cin >> num;
    long long int x = 0, y = 0;
    long long int k = 0;
    cout << "1 1" << endl;
    while (!(x == n - 1 && y == n - 1)) {
      if (x == n - 1) {
        y++;
      } else if (y == n - 1) {
        x++;
      } else {
        bool b = (num >> k) & 1;
        if ((v[y][x + 1] >> k) == b) {
          x++;
        } else {
          y++;
        }
      }
      k++;
      cout << y + 1 << " " << x + 1 << endl;
    }
  }
}
