#include<iostream>
#include<cstdio>
#include<algorithm>
#include<queue>
#define ll long long
using namespace std;
int n,m;
vector<int> ans[2000005];
struct node{
int id;
ll s,t;
}a[2000005];
struct node2{
int id;
ll v;
};
bool cmp(node a,node b){
return a.t<b.t;
}
struct cmp2{
bool operator()(node2 a,node2 b){
if(a.v==b.v) return a.v>b.v;
return a.v>b.v;
}
};
struct cmp3{
bool operator()(node2 a,node2 b){
return a.id>b.id;
}
};
priority_queue<node2,vector<node2>,cmp2> q1;
priority_queue<node2,vector<node2>,cmp3> q2;//bx,x
int main(){
// freopen("in","r",stdin);
// freopen("outm","w",stdout);
scanf("%d%d",&n,&m);
for(int i=1;i<=n;++i){
ll s,t;
scanf("%lld%lld",&s,&t);
a[i]={i,s,t};
}
sort(a+1,a+1+n,cmp);
for(int i=1;i<=m;++i){
q2.push({i,0});
}
for(int i=1;i<=n;++i){
// cout<<"/*";
/* while(!q2.empty()){
if(q2.top().v>a[i].t){
q1.push(q2.top());
q2.pop();
}
else break;
} //cout<<"//";*/
while(!q1.empty()){
if(q1.top().v<=a[i].t){
q2.push(q1.top());
q1.pop();
}
else break;
}
node2 tmp;
/* if(!q2.empty()) tmp=q2.top(),q2.pop();
else tmp=q1.top(),q1.pop();
// cout<<tmp.id<<" "<<tmp.v<<en
dl;
ans[tmp.id].push_back(a[i].id);
tmp.v=max(tmp.v,a[i].t)+a[i].s;
q1.push(tmp);*/
if(!q2.empty()){
tmp=q2.top(),q2.pop();
ans[tmp.id].push_back(a[i].id);
tmp.v=a[i].t+a[i].s;
q1.push(tmp);
}
else {
tmp=q1.top(),q1.pop();
ans[tmp.id].push_back(a[i].id);
tmp.v=tmp.v+a[i].s;
q1.push(tmp);
}
}
for(int i=1;i<=m;++i){
printf("%d ",ans[i].size());
int k=ans[i].size();
sort(ans[i].begin(),ans[i].end());
for(int j=0;j<k;++j){
printf("%d ",ans[i][j]);
}
puts("");
}
return 0;
}