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

using namespace std;

vector<pair<int, int>> ZapisiTacke(int N){
    vector<pair<int, int>> tacke(N+1);
    tacke[1] = {0, 1};
    for (int i = 2; i <= N; i++)
        tacke[i] = {i, 0};
    return tacke;
}

int f;

bool A(int a, int b) {
    return (Pitaj(a, b, f) == -1);
}

vector<int> Resi(int N, int Q){
    vector<int> res(N+1);
    for (int i = 1; i <= N; i++) {
        int a = 1, b = 2, c = 3, d = 4;
        if (a == i)
            a = 5;
        if (b == i)
            b = 5;
        if (c == i)
            c = 5;
        if (d == i)
            d = 5;
        if (Pitaj(i, a, b) != 0 and Pitaj(i, c, d) != 0) {
            res[i] = 1;
            f = i;
            break;
        }
    }
    //cout << f << endl;
    vector<int> v;
    for (int i = 1; i <= N; i++) {
        if (i == f)
            continue;
        v.push_back(i);
    }
    /*for (int x : v)
        cout << x << " ";
    cout << endl;*/
    sort(v.begin(), v.end(), A);
    /*for (int x : v)
        cout << x << " ";
    cout << endl;*/
    int c = N;
    for (int i = 0; i < N - 1; i++) {
        //if (c == f)
        //    c--;
        res[v[i]] = c;
        c--;
    }
    return res;
}