#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;
}

int sol[1005], manji[1005];

vector<pair<int, int>> ZapisiTacke(int n)
{
    vector<pair<int, int>> V;
    if(n > 50)
    {
        for(int i = 0; i <= n; i++)
        {
            if(i == 2 or i == n - 1) V.push_back({i, 1});
            else V.push_back({i, 0});
        }
        return V;
    }
    else
    {
        for(int i = 0; i <= n; i++)
        {
            if(i == 1) V.push_back({0, 0});
            else V.push_back({1, i});
        }
        return V;
    }
};
vector<int> Resi(int n, int q)
{
    vector<int> V;
    int idx, id1, id2, id3;
    for(int i = 1; i < n - 1; i++)
    {
        if(Pitaj(i, i + 1, i + 2) != 0)
        {
            id1 = i;
            id2 = i + 1;
            id3 = i + 2;
            break;
        }
    }
    if(id1 == 1 or id1 == 2)
    {
        if(Pitaj(id1, n/2, n/2 + 1) != 0) idx = id1;
    }
    else
    {
        if(Pitaj(id1, 1, 2) != 0) idx = id1;
    }
    if(id2 == 2 or id2 == 3)
    {
        if(Pitaj(id2, n, n - 1) != 0) idx = id2;
    }
    else
    {
        if(Pitaj(id2, 2, 3) != 0) idx = id2;
    }
    if(id3 == 3 or id3 == 4)
    {
        if(Pitaj(id3, n, n - 1) != 0) idx = id3;
    }
    else
    {
        if(Pitaj(id3, 3, 4) != 0) idx = id3;
    }

    if(n > 50)
    {
        if(Pitaj(1, 2, 3) == -1) for(int i = 0; i <= n; i++) V.push_back(i);
        else for(int i = n + 1; i; i--) V.push_back(i);
    }
    else
    {
        //    cout << idx << "\n";
        for(int i = 1; i <= n; i++)
        {
            if(i == idx) continue;
            for(int j = 1; j <= n; j++)
            {
                if(i == j) continue;
                if(j == idx) continue;
    //            cout << idx << " " << i << " " << j << "\n";
                if(Pitaj(idx, i, j) == -1) manji[i]++;
            }
        }
        for(int i = 1; i <= n; i++) sol[i] = manji[i] + 2;
        V.push_back(0);
        sol[idx]--;
        for(int i = 1; i <= n; i++) V.push_back(sol[i]);
    }
    return V;
};