#include <iostream>
#include <algorithm>
#include <vector>
#include <bits/stdc++.h>
#define int long long
using namespace std;
int n,m,minn,sum;
vector<int>ve[200005];
int ans[200005];
struct ho
{
int xx,yy,id;
}a[200005];
bool cmp(ho w,ho w2)
{
return w.yy < w2.yy;
}
struct node
{
int ze,ye,maxx,us;
}tr[2000005];
void pushup(int x)
{
tr[x].maxx = min(tr[x * 2 + 1].maxx,tr[x * 2 + 2].maxx);
}
void build(int x,int l,int r)
{
tr[x] = {l,r,0,0};
if(l == r)return ;
int mid = (l + r) >> 1;
build(x * 2 + 1,l,mid);
build(x * 2 + 2,mid + 1,r);
}
int query(int x)
{
if(tr[x].ze == tr[x].ye)return tr[x].ze;
if(tr[x * 2 + 1].maxx - sum <= 0)return query(x * 2 + 1);
if(tr[x * 2 + 2].maxx - sum <= 0)return query(x * 2 + 2);
if(tr[x * 2 + 1].maxx <= tr[x * 2 + 2].maxx)return query(x * 2 + 1);
return query(x * 2 + 2);
}
void update(int x,int l,int k)
{
if(tr[x].ze == tr[x].ye)
{
tr[x].maxx = tr[x].maxx - tr[x].us + k;
tr[x].us = k;
return ;
}
int mid = (tr[x].ze + tr[x].ye) >> 1;
if(l <= mid)update(x * 2 + 1,l,k);
else update(x * 2 + 2,l,k);
pushup(x);
}
signed main()
{
cin >> n >> m;
build(0,1,n);
for(int i = 1;i <= m;i ++)
cin >> a[i].xx >> a[i].yy,a[i].id = i;
sort(a + 1,a + m + 1,cmp);
for(int i = 1;i <= m;i ++)
{
int id = query(0);
update(0,id,a[i].xx + sum);
ans[id] ++;
ve[id].push_back(a[i].id);
sum += a[i + 1].yy - a[i].yy;
}
for(int i = 1;i <= n;i ++)
{
cout << ans[i] << " ";
sort(ve[i].begin(),ve[i].end());
for(int j = 0;j < ve[i].size();j ++)cout << ve[i][j] << " ";
cout << '\n';
}
}