#include<vector>
using namespace std;
vector <int> vect;
int idx,vis[1005][1005],manj[1005][1005];

std::vector<int> Nadji(int N, int K) {

    int n=N;

    for (int i=1;i<=n;i++) {
        for (int j=1;j<=n;j++) {
            vis[i][j]=Pitaj(i,j);
        }
    }

    for (int i=1;i<=n;i++) {
        idx=1;
        for (int j=2;j<=n;j++) {
            if (vis[i][j] > vis[i][idx]) idx=j;
        }
        manj[i][idx]++;
    }

    for (int j=1;j<=n;j++) {
        idx=1;
        for (int i=2;i<=n;i++) {
            if (vis[i][j] < vis[i][idx]) idx=i;
        }
        manj[idx][j]++;
    }

    for (int i=1;i<=n;i++) {
        for (int j=1;j<=n;j++) {
            if (manj[i][j] == 2) {
                vect.push_back(i);
                vect.push_back(j);
            }
        }
    }

    return vect;
}