using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace chokudaiContest001 {
class Program {
const int N = 30;
int[] dx = { 1, 0, -1, 0 },
dy = { 0, 1, 0, -1 };
int[,] board = new int[N + 2,N + 2];
static void Main(string[] args) {
new Program().calc();
}
void calc() {
Scanner cin = new Scanner();
foreach (int y in Enumerable.Range(0, N + 2)) {
foreach (int x in Enumerable.Range(0, N + 2)) {
board[x, y] = -1;
}
}
foreach (int y in Enumerable.Range(1, N)) {
foreach (int x in Enumerable.Range(1, N)) {
board[x, y] = cin.nextInt();
}
}
foreach (int y in Enumerable.Range(1, N)) {
foreach (int x in Enumerable.Range(1, N)) {
int loop = board[x, y];
foreach(int i in Enumerable.Range(0, loop)) {
outputAndMoveLoop(x, y);
}
}
}
}
void outputAndMoveLoop(int x, int y) {
output(x, y);
board[x, y] -= 1;
foreach(int i in Enumerable.Range(0, 4)) {
int tx = x + dx[i];
int ty = y + dy[i];
if(0 < board[tx, ty] && board[x, y] == board[tx, ty]) {
outputAndMoveLoop(tx, ty);
return;
}
}
}
void output(int x, int y) {
Console.WriteLine("{0} {1}", x, y);
}
void debugBoard() {
foreach (int y in Enumerable.Range(0, N + 2)) {
foreach (int x in Enumerable.Range(0, N + 2)) {
Console.Write(board[x, y]);
Console.Write(" ");
}
Console.WriteLine();
}
Console.WriteLine();
}
}
class Scanner {
string[] s;
int i;
char[] cs = { ' ' };
public Scanner() {
s = new string[0];
i = 0;
}
public string next() {
if (i < s.Length) return s[i++];
string st = Console.ReadLine();
while (st == "") st = Console.ReadLine();
s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
i = 0;
return next();
}
public int nextInt() {
return int.Parse(next());
}
public long nextLong() {
return long.Parse(next());
}
public double nextDouble() {
return double.Parse(next());
}
}
}