#include<bits/stdc++.h>
#define maxn 200005
#define pii pair<int,int>
#define mk make_pair
using namespace std;

int n;

struct node {int x,y,id;}poi[maxn];

bool cmp1(node i,node j)
{
	return i.x<j.x;
}

int ans[maxn],siz[maxn];

set< pii >	sets;
set< pii >::iterator it;

int fa[maxn];

int find(int x)
{
	return fa[x]==x ? x:fa[x]=find(fa[x]);
}

signed main()
{
	cin>>n;
	for(int i=1;i<=n;i++)	cin>>poi[i].x>>poi[i].y,poi[i].id=fa[i]=i,siz[i]=1;
	sort(poi+1,poi+n+1,cmp1);
	sets.insert(mk(9999999,9999999));
	for(int i=1;i<=n;i++)
	{
		it=sets.begin();
		if((*it).first<poi[i].y)
		{
			while((*it).first<poi[i].y)
			{
				int fx=find(poi[i].id),fy=find((*it).second);
				if(fx!=fy)
				{
					fa[fx]=fy;
					siz[fy]+=siz[fx];
				}
				it++;
			}
		}
		else sets.insert(mk(poi[i].y,poi[i].id));
	}
	for(int i=1;i<=n;i++)
		cout<<siz[find(i)]<<endl;
	
		
} 