#include <bits/stdc++.h>
using namespace std;
const int N=200500;
struct P{
	int x,y,id;
}p[N];
int n,fa[N],sum[N],out[N];
set<int> sp;

bool cmp(P a,P b){return a.x<b.x;}

inline int findfa(int x){
	if(x==fa[x]) return x;
	return x=findfa(fa[x]);
}

inline void hb(int x,int y){
	int u=findfa(x),v=findfa(y);
	if(u<v) swap(u,v);
	sum[v]+=sum[u];
	fa[u]=v;
}

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d%d",&p[i].x,&p[i].y);
		p[i].id=i;
	}
	sort(p+1,p+1+n,cmp);
	for(int i=1;i<=n;i++) fa[i]=i,sum[i]=1;
	for(int i=1;i<=n;i++) {
		while(!sp.empty() && (*sp.begin())<p[i].y) {
			hb(p[i].y,(*sp.begin()));
			sp.erase(sp.begin());
		}
		sp.insert(findfa(p[i].y));
	}
	for(int i=1;i<=n;i++)
		out[p[i].id]=sum[findfa(p[i].y)];
	for(int i=1;i<=n;i++)
		printf("%d\n",out[i]);
	return 0;
}