#include <bits/stdc++.h>

#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define mod 1000000007
#define ios ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define pb push_back

using namespace std;

static int n, k;
static int question_num = 0;
static int h[1001][1001];


int d[1010][1010];
bool x[1010][1010],y[1010][1010];

int Pitaj(int i, int j);

//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;
}