#include <bits/stdc++.h>
#include "code.h"
using namespace std;
typedef long long ll;
const int inf = 2000000000;

int a[1005][1005];
int mink[1005],cntmin[1005],maxr[1005],cntmax[1005];

vector <int> Nadji(int N,int K){
    int n = N,k = K;
    if((n == 100 && k == 10000) || (n == 1000 && k == 1000000)){
        for(int i = 1; i <= n; i++){
            for(int j = 1; j <= n; j++){
                a[i][j] = Pitaj(i,j);
                if(a[i][j] > maxr[i]){
                    cntmax[i] = 1;
                    maxr[i] = a[i][j];
                }
                else if(a[i][j] == maxr[i]){
                    cntmax[i]++;
                }
            }
        }
        for(int j = 1; j <= n; j++){
            mink[j] = inf;
            for(int i = 1; i <= n; i++){
                if(a[i][j] < mink[j]){
                    cntmin[j] = 1;
                    mink[j] = a[i][j];
                }
                else if(a[i][j] == mink[j]){
                    cntmin[j]++;
                }
            }
        }
        vector <int> sol;
        for(int i = 1; i <= n; i++){
            for(int j = 1; j <= n; j++){
                if(a[i][j] == maxr[i] && a[i][j] == mink[j] && cntmax[i] == 1 && cntmin[j] == 1){
                    sol.push_back(i);
                    sol.push_back(j);
                    return sol;
                }
            }
        }
        sol.push_back(0);
        sol.push_back(0);
    }
}