//2623177 2011-08-11 21:39:26 Accepted 3317 C++ 0 180 ylwh@Unknown
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <algorithm>
using namespace std;
#define N 101
#define M 101
struct node
{
int in, leave;
int num, room;
}s[N];
int cmp(struct node a, struct node b)
{
if(a.in != b.in)
return a.in < b.in;
else
return a.leave < b.leave;
}
int cmp2(struct node a, struct node b)
{
return a.num < b.num;
}
int main(void)
{
int room[M], in, leave, m, n, i, j;
while(scanf("%d%d",&n, &m), n)
{
memset(room, 0, sizeof(room));
for(i=1; i<=n; i++)
{
scanf("%d%d",&s[i].in, &s[i].leave);
s[i].num = i;
}
sort(s+1, s+n+1, cmp);
for(i=1; i<=n; i++)
{
for(j=1; j<=m; j++)
if(s[i].in >= room[j])
{
s[i].room = j;
room[j] = s[i].leave;
goto X;
}
s[i].room = 0;
X: continue;
}
sort(s+1, s+n+1, cmp2);
for(i=1; i<=n; i++)
printf("%d\n", s[i].room);
}
return 0;
}