#include <iostream>
using namespace std;
int main()
{
int matr[32][32] = { 0 }, N, i, j;
cin >> N;
for (int linie = 1; linie <= N; linie++)
for (int coloană = 1; coloană <= N; coloană++)
cin >> matr[linie][coloană];
cin >> i >> j;
while (matr[i][j])
cout << matr[i++][j++] << ' ';
return 0;
}