#include <bits/stdc++.h>
#include "code.h"

using namespace std;

int blok[1000][1000];

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

    bool doublerows[N];
    bool doublecolumns[N];
    int maxrows[N];
    int mincolumns[N];

    for (int i = 0; i < N; i++){
        for (int j = 0; j < N; j++){
            if(blok[i][j] > maxrows[i]){
                doublerows[i] = false;
                maxrows[i] = blok[i][j];
            }
            else {
                if (blok[i][j] == maxrows[i]){
                    doublerows[i] = true;
                }
            }

            if(blok[i][j] < mincolumns[j]){
                doublecolumns[j] = false;
                mincolumns[j] = blok[i][j];
            }
            else {
                if (blok[i][j] == mincolumns[j]){
                    doublecolumns[j] = true;
                }
            }
        }
    }

    bool found = false;
    int ee = -1;
    int yooh = -1;

    for (int i = 0; i < N && !found; i++){
        for (int j = 0; j < N && !found; j++){
            if (!doublecolumns[j] && !doublerows[i] && mincolumns[j] == maxrows[i]){
                found = true;
                ee = i+1;
                yooh = j+1;
            }
        }
    }

    vector<int> ljakse;
    ljakse.push_back(ee);
    ljakse.push_back(yooh);

    return ljakse;

}