#include <iostream>
#include <string>
#include <vector>
using namespace std;
int map[100][100];
int node_num;
int path[5] = { 0 };
void input() {
cin >> node_num;
for (int i = 0; i < node_num; i++) {
for (int j = 0; j < node_num; j++) {
cin >> map[i][j];
}
}
}
void run(int num, int lev) {
if (lev == 2) {
for (int i = 0; i < 3; i++) {
cout << path[i] << ' ';
}
cout << '\n';
return;
}
for (int i = 0; i < node_num; i++) {
if (map[num][i] == 1) {
int next = i;
path[lev+1] = i;
run(next,lev+1);
path[lev + 1] = 0;
}
}
}
int main() {
path[0] = 0;
input();
run(0,0);
return 0;
}