#include <iostream>
#include <cstdio>
#include <cstring>
#include <climits>
#include <vector>
#include <algorithm>
using namespace std;
#define SIZE 10005
int max_n = INT_MIN;
struct Node{
Node():left( 0 ), right( 0 ), ID( 0 ){}
int left;
int right;
int ID;
};
Node arr[SIZE];
int level[SIZE];
int countNum[SIZE];
int cmp ( const Node& a, const Node& b ){
if( a.right == b.right )
return a.left < b.left;
return a.right > b.right;
}
int lowBit( int index ){
return index & ( - index );
}
void update( int index, const int& val ){
while( index < max_n + 1 ){
countNum[index] += val;
index += lowBit( index );
}
}
int getSum( int index ){
int sum = 0;
while( index >= 1 ){
sum += countNum[index];
index -= lowBit( index );
}
return sum;
}
int main(){
while( true ){
memset( level, 0, sizeof(level) );
int nCase;
scanf( "%d", &nCase );
vector< Node > arr( nCase + 1 );
if( nCase == 0 )
break;
for( int i = 0; i < nCase; ++i ){
int x, y;
scanf( "%d%d", &x, &y );
if( max_n < y )
max_n = y;
x++;
y++;
arr[i].left = x;
arr[i].right = y;
arr[i].ID = i;
}
sort( arr.begin(), arr.end(), cmp );
for( int i = 0; i < nCase; ++i ){
if( arr[i].left == arr[i - 1].left && arr[i].right == arr[i - 1].right )
level[arr[i].ID] = level[arr[i - 1].ID];
else
level[arr[i].ID] = getSum( arr[i].left );
update( arr[i].left, 1 );
}
for( int i = 0; i < nCase; ++i )
printf( "%d ", level[i] );
cout << endl;
}
return 0;
}