#include <bits/stdc++.h>
#include "code.h"
using namespace std;

namespace {
    static vector<pair<int, int>> points;
    static vector<int> p;
    static int n;
    static int q;
    static int qt;
}
vector<pair<int, int>> ZapisiTacke(int n){
    vector<pair<int , int>> tacke(n+1);
    tacke[1] = {1 , 0};
    tacke[2] = {2 , 0};
    tacke[3] = {3 , 0};
    for(int i = 4; i<n; i++){
        tacke[i] = {i , 0};
    }
    tacke[n] = {n+1 , 1};
    return tacke;
}

int tacka = 0;

bool kkkomparator(int a , int b){
    if(Pitaj(a , b , tacka) == 1){
        //dobar raspored:
        return true;
    }else{
        return false;
    }
}

vector<int> Resi(int n, int q){
    vector<int> resenje(n-1);
    //pusback res
    int br = 0 , res = -1;
    for(int i = 1; i<=n - 2; i++){
        if(Pitaj(i , i+1 , i+2) != 0){
            br = i;
            break;
        }
    }
    if(br == 0){
        while (true){
            br = br;
        }
    }

    if(br > 1){
        if(Pitaj(1 , br , br+1) == 0){
            res = br+2;
        }else if (Pitaj(1 , br , br+2) == 0){
            res = br+1;
        }else{
            res = br;
        }
    }else{
        if(Pitaj(4 , br , br+1) == 0){
            res = br+2;
        }else if (Pitaj(4 , br , br+2) == 0){
            res = br+1;
        }else{
            res = br;
        }
    }

    if(res == -1){
        while (true){
            res = res;
        }
    }

    int nesto = 1;
    for(int i = 0; i<n-1; i++){
        if(nesto == res) nesto++;
        resenje[i] = nesto;
        nesto++;
    }

    tacka = res;
    sort(resenje.begin() , resenje.end() , kkkomparator);

    resenje.push_back(res);
    vector<int> rr(n+1);

    for(int i = 0; i<n; i++){
        rr[i+1] = resenje[i];
    }
    return rr;
}