#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main()
{
ios::sync_with_stdio(0);
cin.tie(0),cout.tie(0);
int n,m,h=1,k;
struct map
{
int x,y;
bool b=1;
} a[1005];
cin>>m>>n>>a[0].x>>a[0].y;
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++)
{
cin>>a[h].x>>a[h].y;
if(a[h].x==0&&a[h].y==0)
{
a[h].b=0;
k=h;
}
h++;
}
for(int i=0;i<k;i++)
{
cout<<a[i].x<<" "<<a[i].y<<endl;
}
}