#include <iostream>
#include <vector>
#include "code.h"

using namespace std;
int matrica[5005][5005];
vector<pair<int, int>> ZapisiTacke(int N){
    vector<pair<int, int>> tacke(N+1);
    for ( int i = 0 ; i < N  ; i++)
    {
        tacke[i] = make_pair(i,0);
    }
    tacke[N] = make_pair(0,1);
    return tacke;
}

vector<int> Resi(int n, int q)
{
    for ( int i = 0 ; i <= n ; i++)
        for ( int j = 0 ; j<= n ; j++) matrica[i][j] = 5;
    vector<int> resenje(n+1);
    int vanprave;
    if (Pitaj(1,2,3) == 0)
    {
        vanprave = 4;
        while(Pitaj(1,2,vanprave) == 0) vanprave++;
    }
    else
    {
        if ( Pitaj(2,3,4) == 0) vanprave = 1;
        else if ( Pitaj(1,3,4) == 0) vanprave = 2;
        else vanprave = 3;
    }
    resenje[vanprave] = n;
    resenje[0] = 0;
    for ( int i = 1 ; i <= n ; i++)
    {
        if ( i != vanprave)
        {
            int br = 1;
            for ( int j = 1 ; j <= n ; j++)
            {
                if ( i != j && j != vanprave)
                {
                    if ( matrica[i][j] != -1 && matrica[i][j] != 1)
                    {
                        matrica[i][j] = Pitaj(vanprave,i,j);
                        matrica[j][i] = -matrica[i][j];
                    }
                    if ( matrica[i][j] == -1) br++;
                }
            }
            resenje[i] = br;
        }
    }
    return resenje;
}