int Pitaj(int i, int j);

vector<int> Nadji(int N, int K) {
	for (int i=1;i<=N;i++){
        for (int j=1;j<=N;j++){
            d[i][j]=Pitaj(i,j);
        }
	}
    for (int i=1;i<=N;i++){
        int m=-1;
        for (int j=1;j<=N;j++)m=max(d[i][j],m);

        int cnt=0;
        for (int j=1;j<=N;j++)if (d[i][j]==m)cnt++;
        if (cnt>1)continue;
        for (int j=1;j<=N;j++)if (m==d[i][j])x[i][j]=true;
    }


    for (int j=1;j<=N;j++){
        int m=1e9;
        for (int i=1;i<=N;i++)m=min(m,d[i][j]);

        int cnt=0;
        for (int i=1;i<=N;i++)if (m==d[i][j])cnt++;
        if (cnt>1)continue;
        for (int i=1;i<=N;i++)if (m==d[i][j])y[i][j]=true;
    }

	vector<int>out;
	out.pb(0),out.pb(0);
    for (int i=1;i<=N;i++){
        for (int j=1;j<=N;j++){
            if (x[i][j] and y[i][j]){
                out[0]=i,out[1]=j;
            }
        }
    }
	return out;
}

int main(){
	cin>>n>>k;

	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= n; j++)
			cin>>h[i][j];

	vector<int> out = Nadji(n, k);

	for (auto i:out)cout<<i<<" ";
    return 0;
}