#include<iostream>
#include<algorithm>
#include<vector>
#include<deque>
using namespace std;
#include<vector>
struct UF{
	int n;
	vector<int>parent,rank;
	UF(int n_=0):n(n_),parent(n_),rank(n_,1)
	{
		for(int i=0;i<n_;i++)parent[i]=i;
	}
	int find(int a){return parent[a]!=a?parent[a]=find(parent[a]):a;}
	bool same(int a,int b){return find(a)==find(b);}
	bool unite(int a,int b)
	{
		a=find(a),b=find(b);
		if(a==b)return false;
		if(rank[a]<rank[b])
		{
			parent[a]=b;
			rank[b]+=rank[a];
		}
		else
		{
			parent[b]=a;
			rank[a]+=rank[b];
		}
		return true;
	}
	int size(int a){return rank[find(a)];}
};
int N;
int main()
{
	cin>>N;
	vector<pair<pair<int,int>,int> >A(N);
	for(int i=0;i<N;i++)
	{
		cin>>A[i].first.first>>A[i].first.second;
		A[i].second=i;
	}
	sort(A.begin(),A.end());
	deque<pair<int,int> >P;
	UF uf(N);
	for(int i=0;i<N;i++)
	{
		int y=A[i].first.second;
		int id=A[i].second;
		int my=y;
		while(!P.empty()&&P.front().first<y)
		{
			uf.unite(id,P.front().second);
			my=min(my,P.front().first);
			P.pop_front();
		}
		P.push_front(make_pair(my,id));
	}
	deque<pair<int,int> >Q;
	for(int i=N;i--;)
	{
		int y=A[i].first.second;
		int id=A[i].second;
		int My=y;
		while(!Q.empty()&&Q.back().first>y)
		{
			uf.unite(id,Q.back().second);
			My=max(My,Q.back().first);
			Q.pop_back();
		}
		Q.push_back(make_pair(My,id));
	}
	for(int i=0;i<N;i++)cout<<uf.size(i)<<endl;
}
