#include <stdio.h>
typedef struct zb
{
int x;
int y;
}zb;
int main()
{
int m, n, x, y;
zb arr[10][10];
scanf("%d%d%d%d", &m, &n, &x, &y);
zb* p = (zb*)arr;
for (int i = 0; i < m; i++)
{
for (int j = 0; j < n; j++)
{
scanf("%d%d", &(arr[i][j].x), &(arr[i][j].y));
}
}
while (x != 0 && y != 0)
{
int tempx = x, tempy = y;
printf("%d %d\n", x, y);
x = (arr[tempx - 1][tempy - 1]).x;
y = (arr[tempx - 1][tempy - 1]).y;
}
return 0;
}