#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()
}