#include <iostream>
#include <fstream>
using namespace std;
ifstream in("maxmat.in");
ofstream out("maxmat.out");
int main()
{
long int a[101][101], n, m, i, j;
in>>n>>m;
for(i=0; i<n; i++)
for(j=0; j<m; j++)
in>>a[i][j];
for(i=0; i<n; i++)
{
int max = a[i][0];
for(j=1; j<m; j++)
if(a[i][j]>max)
max = a[i][j];
for(j=0; j<m; j++)
if(a[i][j]==max)
{
out<<max<<" "<<j+1<<endl;
break;
}
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8ZnN0cmVhbT4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCmlmc3RyZWFtIGluKCJtYXhtYXQuaW4iKTsKb2ZzdHJlYW0gb3V0KCJtYXhtYXQub3V0Iik7CgppbnQgbWFpbigpCnsKICAgIGxvbmcgaW50IGFbMTAxXVsxMDFdLCBuLCBtLCBpLCBqOwogICAgaW4+Pm4+Pm07CiAgICBmb3IoaT0wOyBpPG47IGkrKykKICAgICAgICBmb3Ioaj0wOyBqPG07IGorKykKICAgICAgICAgICAgaW4+PmFbaV1bal07CiAgICBmb3IoaT0wOyBpPG47IGkrKykKICAgIHsKICAgICAgICBpbnQgbWF4ID0gYVtpXVswXTsKICAgICAgICBmb3Ioaj0xOyBqPG07IGorKykKICAgICAgICAgICAgaWYoYVtpXVtqXT5tYXgpCiAgICAgICAgICAgICAgICBtYXggPSBhW2ldW2pdOwogICAgICAgIGZvcihqPTA7IGo8bTsgaisrKQogICAgICAgICAgICBpZihhW2ldW2pdPT1tYXgpCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIG91dDw8bWF4PDwiICI8PGorMTw8ZW5kbDsKICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICB9CiAgICB9CnJldHVybiAwOwp9