#include<bits/stdc++.h>
using namespace std;
#define int long long
int n,m,cnt;
struct az{
int w;
int id;
bool operator < (const az &a) const{
if(a.w == w) return id > a.id;
return w > a.w;
}
};
struct za{
int s;
int t;
int id;
}q[200001];
struct an{
int l;
bool operator < (const an &a) const{
return l > a.l;
}
};
bool cmp(za a,za b){
return a.s < b.s;
}
priority_queue<az> p;
priority_queue<an> ans[200001];
signed main(){
cin >> n >> m;
for(int i = 1; i <= n; i++){
cin >> q[i].t >> q[i].s;
q[i].id = i;
}
sort(q+1,q+n+1,cmp);
az op;
op.w = q[1].s+q[1].t;
op.id = 1;
p.push(op);
an na;
na.l = q[1].id;
ans[++cnt].push(na);
for(int i = 2; i <= n; i++){
op = p.top();
vector<az> pp;
while(op.w <= q[i].s&&!p.empty()){
op.w = 0;
p.pop();
pp.push_back(op);
op = p.top();
}
for(int j = 0; j < pp.size(); j++){
p.push(pp[j]);
}
op = p.top();
if(op.w <= q[i].s){
p.pop();
na.l = q[i].id;
ans[op.id].push(na);
op.w = q[i].s + q[i].t;
p.push(op);
}else{
if(cnt < m){
op.id = ++cnt;
op.w = q[i].s + q[i].t;
na.l = q[i].id;
ans[op.id].push(na);
p.push(op);
}else{
p.pop();
op.w += q[i].t;
na.l = q[i].id;
ans[op.id].push(na);
p.push(op);
}
}
}
for(int i = 1; i <= m; i++){
cout << ans[i].size() << " ";
while(!ans[i].empty()){
cout << ans[i].top().l << " ";
ans[i].pop();
}
cout <<endl;
}
return 0;
}