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

using namespace std;

vector<pair<int, int>> ZapisiTacke(int n){
    vector<pair<int, int>> v(n+1);
    v[1] = {0, 0};

    for(int i = 2; i <= n; i++){
        v[i] = {i-2, 1};
    }
    return v;
}

vector<int> Resi(int n, int q){
    if(q == 20000){
        vector<int> ans1(n+1), ans2(n+1);
        for(int i = 1; i <= n; i++){
            ans1[i] = i;
            ans2[i] = n-i+1;
        }

        if(Pitaj(1, 2, 3) == 0) return ans2;
        return ans1;
    }

    int kec = 1;
    if(Pitaj(1, 2, 3) == 0){
        for(int i = 4; i <= n; i++){
            if(Pitaj(i-2, i-1, i) != 0){
                kec = i; break;
            }
        }
    }
    else if(Pitaj(2, 3, 4) == 0){
        kec = 1;
    }
    else if(Pitaj(3, 4, 5) == 0){
        kec = 3;
    }
    else{
        kec = 2;
    }


    vector<int> ans(n+1);
    ans[0] = 0;
    ans[kec] = 1;

    vector<vector<int>> memo(n+1, vector<int>(n+1));
    for(int i = 0; i <= n; i++){
        for(int j = 0; j <= n; j++){
            memo[i][j] = 67;
        }
    }

    int d = 0;
    for(int i = 1; i <= n; i++){
        if(i == kec) continue;
        d = 0;
        for(int j = 1; j <= n; j++){
            if(i == j || j == kec) continue;

            if(memo[i][j] == 67){
                memo[i][j] = Pitaj(kec, i, j);
                memo[j][i] = -memo[i][j];
            }
            if(memo[i][j] == -1) d++;
        }
        ans[i] = n-d;
    }
    return ans;
}