#include<bits/stdc++.h>
using namespace std;
int main() {
int A[5][5];
int x, y;
for(int i = 0; i < 5; i+=1) {
for(int j = 0; j < 5; j+=1) {
cin >> A[i][j];
if(A[i][j] == 1) x = j; y = i;
}
}
cout << y << endl << x;
// if(A[2][2] == 1) cout << 0;
// else if()
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCmludCBtYWluKCkgewogICAgaW50IEFbNV1bNV07CiAgICBpbnQgeCwgeTsKICAgIGZvcihpbnQgaSA9IDA7IGkgPCA1OyBpKz0xKSB7CiAgICAgICAgZm9yKGludCBqID0gMDsgaiA8IDU7IGorPTEpIHsKICAgICAgICAgICAgY2luID4+IEFbaV1bal07CiAgICAgICAgICAgIGlmKEFbaV1bal0gPT0gMSkgeCA9IGo7IHkgPSBpOwogICAgICAgIH0KICAgIH0KICAgIGNvdXQgPDwgeSA8PCBlbmRsIDw8IHg7CiAgICAvLyBpZihBWzJdWzJdID09IDEpIGNvdXQgPDwgMDsKICAgIC8vIGVsc2UgaWYoKQp9