#include <bits/stdc++.h>
using namespace std;
int main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(NULL);
  int ans, n, con = 0;
  cin >> n;
  bool trace[n][n];
  memset(trace, 1, sizeof(trace));
  int g[n][n];
  int p[n * n];
  memset(g, 0, sizeof(g));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      g[j][i] = ++con;
    }
  }
  int t_x, t_y;
  for (int x = 0; x < n * n; x++) {
    cin >> p[x];
    p[x] = 3;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        if (p[x] == g[j][i]) t_x = j;
        t_y = i;
      }
    }
    if (t_x - 1 < 0 || t_x + 1 > n - 1 || t_y - 1 > n - 1 || t_y + 1 > n - 1) {
    } else {
      if (trace[t_x - 1][t_y] && trace[t_x + 1][t_y] && trace[t_x][t_y - 1] &&
          trace[t_x][t_y + 1])
        ans++;
    }
    trace[t_x][t_y] = 0;
    cout << t_x << '\n' << t_y << '\n';
  }
  return 0;
}
