#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;
}
map<int,int>mpy;
int sn,nn,ostatak;
vector<int>x_par[1000];
vector<int>y_par[1000];
vector<pair<int, int>> ZapisiTacke(int n){
vector<pair<int,int>>t;
t.resize(n+1);
sn=sqrt(n)-2;
cout<<sn<<endl;
t[1]={-1,-1};
int cnt=1;
for(int i = 1;i<=n;i++){
if(i%sn==0)
cnt+=100;
t[i+1]={i%sn,(i/sn)*cnt};
}
return t;
}
void roll(){
vector<int>trojka(3);
while(true){
int x,y,z;
x=(rand()%n)+1;
y=(rand()%n)+1;
z=(rand()%n)+1;
int odg;
if(x!=y&&z!=y&&x!=z)
odg=Pitaj(x,y,z);
if(odg==0){
trojka[0]=x;
trojka[1]=y;
trojka[2]=z;
break;
}
}
cout<<trojka[0]<<" "<<trojka[1]<<' '<<trojka[2]<<" "<<qt<<endl;
vector<int>kol;
kol.push_back(trojka[0]);
kol.push_back(trojka[1]);
kol.push_back(trojka[2]);
vector<int>pl;
vector<int>mi;

for(int i  = 1;i<=n;i++){
if(i!=trojka[2]&&i!=trojka[1]&&i!=trojka[0]){
int odg=Pitaj(trojka[0],trojka[1],i);
if(odg==0)
kol.push_back(i);
if(odg==-1)
mi.push_back(i);
if(odg==1)
pl.push_back(i);
}
}
cout<<pl.size()<<" "<<mi.size()<<" "<<kol.size()<<endl;
nn=0;
while(nn*sn<n)
nn++;
ostatak=n-(nn-1)*sn;
cout<<nn<<" "<<ostatak<<endl;
if(kol.size()==sn){
if(mi.size()%sn==0){
int h=mi.size()/sn;
//kol je h-ta po redu
for(int i = 0;i<kol.size();i++)
x_par[h].push_back(kol[i]);
}
else if(pl.size()%sn==0){
int h=pl.size()/sn;
//kol je h-ta po redu
for(int i = 0;i<kol.size();i++)
x_par[h].push_back(kol[i]);
}
}
else{
roll();
}
}

void nadji_y(int x,int h){
vector<int>trojka(3);
while(true){
int y,z;
y=(rand()%n)+1;
z=(rand()%n)+1;
int odg;
if(x!=y&&z!=y&&x!=z)
odg=Pitaj(x,y,z);
if(odg==0){
trojka[0]=x;
trojka[1]=y;
trojka[2]=z;
break;
}
}

vector<int>kol;
kol.push_back(trojka[0]);
kol.push_back(trojka[1]);
kol.push_back(trojka[2]);
vector<int>pl;
vector<int>mi;

for(int i  = 1;i<=n;i++){
if(i!=trojka[2]&&i!=trojka[1]&&i!=trojka[0]&&mpy[i]==0){
int odg=Pitaj(trojka[0],trojka[1],i);
if(odg==0)
kol.push_back(i);
if(odg==-1)
mi.push_back(i);
if(odg==1)
pl.push_back(i);
}
}
for(int i = 0;i<n;i++)
y_par[h].push_back(kol[i]);

}


vector<int> Resi(int n, int q){
/*
int br=0;
int ii=1;
for(int j = 1;j<=n;j++)
for(int k = 1;k<=n;k++)
if(ii!=k&&ii!=j&&j!=k){
int x=Pitaj(ii,j,k);
if(x==0&&points[ii].first!=points[j].first&&points[ii].second!=points[j].second
   &&points[ii].first!=points[k].first&&points[ii].second!=points[k].second
   &&points[k].first!=points[j].first&&points[k].second!=points[j].second)
br++;
}
cout<<br<<endl;
*/
roll();
bool b=false;
for(int i = 0;i<n;i++)
if(x_par[i].size()!=0)
b=true;
if(b)
for(int i = 0;i<n;i++)
if(x_par[i].size()!=0){
for(int j = 0;j<x_par[i].size();j++)
mpy[x_par[i][j]]=1;
for(int j = 0;j<x_par[i].size();j++)
nadji_y(x_par[i][j],j);
}
cout<<"yaay uspeo sam posle "<<q-qt<<" rollova"<<endl;

for(int i =1;i<=n;i++)
cout<<points[i].first<<" "<<points[i].second<<endl;
vector<int>a(n+1);
for(int i = 1;i<=n;i++)
a[i]=i;
return a;
}

int Pitaj(int i, int j, int k) {
    qt--;
    assert(1 <= i && i <= n);
    assert(1 <= j && j <= n);
    assert(1 <= k && k <= n);
    assert(i != j && i != k && j != k);
    assert(qt >= 0);

    int pi = p[i];
    int pj = p[j];
    int pk = p[k];

    assert(1 <= pi && pi <= n);
    assert(1 <= pj && pj <= n);
    assert(1 <= pk && pk <= n);

    auto [ax, ay] = points[pi];
    auto [bx, by] = points[pj];
    auto [cx, cy] = points[pk];

    long long cross =
        1LL * (bx - ax) * (cy - ay) -
        1LL * (by - ay) * (cx - ax);

    if (cross > 0) return 1;
    if (cross < 0) return -1;
    return 0;
}

int main() {
    cin >> n >> q;

    points = ZapisiTacke(n);
    set<pair<int, int>> used_points;

    assert((int)points.size() == n + 1);

    for (int i = 1; i <= n; i++) {
        int x, y;
        x = points[i].first;
        y = points[i].second;

        assert(!used_points.count({x, y}));
        used_points.insert({x, y});
        assert(-1000000000LL <= x && x <= 1000000000LL);
        assert(-1000000000LL <= y && y <= 1000000000LL);
    }

    p.resize(n + 1);
    for (int i = 1; i <= n; i++) {
        p[i]=i;
    }
    vector<int> provera_permutacije = p;
    sort(provera_permutacije.begin()+1, provera_permutacije.end());
    for(int i = 1; i<=n; i++){
        assert(provera_permutacije[i] == i);
    }
    qt = q;

    vector<int> ans = Resi(n, q);

    assert((int)ans.size() == n + 1);

    for (int i = 1; i <= n; i++) {
        if (i > 1) cout << ' ';
        cout << ans[i];
    }
    cout << '\n';

    return 0;
}