/*
{By GWj
*/
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define POB pop_back
#define ff fflush(stdout)
#define fastio ios::sync_with_stdio(false)
#define R(a) cin>>a
#define R2(a,b) cin>>a>>b
#define check_min(a,b) a=min(a,b)
#define check_max(a,b) a=max(a,b)
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
/*}
*/
const int MAXN=200000+20;
int fa[MAXN],is[MAXN],siz[MAXN];
int n;
mp cit[MAXN];
int root(int x){
	if(fa[x]==x) return x;
	return fa[x]=root(fa[x]);
}
void merge(int u,int v){
	if(root(u)==root(v)) return ;
	siz[root(v)]+=siz[root(u)];
	fa[root(u)]=root(v);
}
int main(){
	fastio;
	R(n);
	rb(i,1,n)
		fa[i]=i,siz[i]=1;
	rb(i,1,n){
		R2(cit[i].FIR,cit[i].SEC);
		is[i]=cit[i].FIR;
	}
	sort(cit+1,cit+1+n);
	int las=0,mi=INF;
	rb(i,1,n){
		check_min(mi,cit[i].SEC);
		if(mi==n-i+1){
			rb(j,las+1,i)
				if(j!=las+1)
					merge(j,j-1);
			las=i;
		}
	}
	rb(i,1,n)  cout<<siz[root(is[i])]<<endl;
	return 0;
}
