#include <bits/stdc++.h>
using namespace std;
struct P{int x,y;};
double dist(const P &a,const P &b){
double dx=a.x-b.x, dy=a.y-b.y;
return sqrt(dx*dx+dy*dy);
}
int main(){
ios::sync_with_stdio(false); cin.tie(nullptr);
int N,K; cin>>N>>K;
vector<P> pts(N);
for(int i=0;i<N;i++) cin>>pts[i].x>>pts[i].y;
const int GW=10, GH=14, CELLS=GW*GH, MAXC=814000;
vector<vector<int>> cluster(CELLS);
for(int i=0;i<N;i++){
int gx = (long long)pts[i].x*GW/(MAXC+1);
int gy = (long long)pts[i].y*GH/(MAXC+1);
gx=max(0,min(GW-1,gx)); gy=max(0,min(GH-1,gy));
cluster[gy*GW+gx].push_back(i);
}
vector<int> empty;
for(int i=0;i<CELLS;i++) if(cluster[i].empty()) empty.push_back(i);
auto largest_idx=[&]()->int{
int mx=0, idx=0;
for(int i=0;i<CELLS;i++) if(cluster[i].size()>mx){ mx=cluster[i].size(); idx=i; }
return idx;
};
while(!empty.empty()){
int to=empty.back(), from=largest_idx();
if(from==to) break;
if(cluster[from].size()<=1){ empty.pop_back(); continue; }
cluster[to].push_back(cluster[from].back());
cluster[from].pop_back();
empty.pop_back();
}
auto build_nn=[&](const vector<int>& idxs)->vector<int>{
int m=idxs.size(); if(m==0) return {};
vector<int> tour; tour.reserve(m);
vector<char> used(m,0);
int cur=0; tour.push_back(idxs[cur]); used[cur]=1;
for(int step=1;step<m;step++){
int best=-1; double bd=1e300;
for(int j=0;j<m;j++) if(!used[j]){
double d=dist(pts[tour.back()], pts[idxs[j]]);
if(d<bd){ bd=d; best=j; }
}
used[best]=1; tour.push_back(idxs[best]);
}
return tour;
};
auto tour_len=[&](const vector<int>& t)->double{
int m=t.size(); if(m<=1) return 0.0;
double s=0; for(int i=0;i<m;i++) s+=dist(pts[t[i]], pts[t[(i+1)%m]]);
return s;
};
auto two_opt=[&](vector<int>& t,int iter_limit){
int n=t.size(); if(n<=2) return;
bool improved=true; int it=0;
while(improved && it<iter_limit){
improved=false;
for(int i=0;i<n-1;i++){
for(int j=i+2;j<n;j++){
if(i==0 && j==n-1) continue;
double before=dist(pts[t[i]],pts[t[i+1]])+dist(pts[t[j]],pts[t[(j+1)%n]]);
double after=dist(pts[t[i]],pts[t[j]])+dist(pts[t[i+1]],pts[t[(j+1)%n]]);
if(after+1e-12<before){ reverse(t.begin()+i+1, t.begin()+j+1); improved=true; goto NEXT; }
}
}
NEXT: it++;
}
};
vector<vector<int>> tours(CELLS);
for(int i=0;i<CELLS;i++){ tours[i]=build_nn(cluster[i]); if(tours[i].size()>1) two_opt(tours[i],200); }
vector<double> len(CELLS); for(int i=0;i<CELLS;i++) len[i]=tour_len(tours[i]);
auto neighbors=[&](int id)->vector<int>{
vector<int> res; int gx=id%GW, gy=id/GW;
for(int dy=-1;dy<=1;dy++) for(int dx=-1;dx<=1;dx++){
if(dx==0 && dy==0) continue;
int nx=gx+dx, ny=gy+dy;
if(nx>=0 && nx<GW && ny>=0 && ny<GH) res.push_back(ny*GW+nx);
} return res;
};
for(int iter=0;iter<250;iter++){
int worst=max_element(len.begin(),len.end())-len.begin();
vector<int> nbs=neighbors(worst); double bestgain=1e-12;
int best_from=-1,best_to=-1,best_pos=-1;
for(int nb:nbs){
if(nb<0 || nb>=CELLS) continue;
int m_w=tours[worst].size(); if(m_w==0) continue;
for(int pos=0;pos<m_w;pos++){
int city=tours[worst][pos];
int prev=tours[worst][(pos-1+m_w)%m_w], next=tours[worst][(pos+1)%m_w];
double removeCost=dist(pts[prev],pts[city])+dist(pts[city],pts[next])-dist(pts[prev],pts[next]);
double bestInsert=1e300; int bestI=0;
int m_nb=tours[nb].size();
if(m_nb==0){ bestInsert=0.0; bestI=0; }
else for(int j=0;j<m_nb;j++){
int a=tours[nb][j], b=tours[nb][(j+1)%m_nb];
double ins=dist(pts[a],pts[city])+dist(pts[city],pts[b])-dist(pts[a],pts[b]);
if(ins<bestInsert){ bestInsert=ins; bestI=j+1; }
}
double newWorst=len[worst]-removeCost;
double newNb=len[nb]+bestInsert;
double newMax=max(newWorst,newNb), oldMax=max(len[worst],len[nb]);
double gain=oldMax-newMax;
if(gain>bestgain){ bestgain=gain; best_from=pos; best_to=nb; best_pos=bestI; }
}
}
if(best_from==-1) break;
int city=tours[worst][best_from]; tours[worst].erase(tours[worst].begin()+best_from);
if(best_pos>(int)tours[best_to].size()) best_pos=tours[best_to].size();
tours[best_to].insert(tours[best_to].begin()+best_pos, city);
if(tours[worst].size()>1) two_opt(tours[worst],60);
if(tours[best_to].size()>1) two_opt(tours[best_to],60);
len[worst]=tour_len(tours[worst]); len[best_to]=tour_len(tours[best_to]);
}
for(int i=0;i<K;i++){
if(i<(int)tours.size()){
cout<<tours[i].size();
for(int v:tours[i]) cout<<" "<<v+1;
cout<<"\n";
} else cout<<"1 1\n";
}
return 0;
}