#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
	template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
	template <class Arg1, class... Args>
	void __f(const char* names, Arg1&& arg1, Args&&... args) {
		const char* sep = strchr(names + 1, ',');
		cerr.write(names, sep - names) << " : " << arg1 << "  ";
		__f(sep + 1, args...);
	}
#else
#define trace(...) 0
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("popcnt")
#pragma GCC target("avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#endif
 
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<int,pii> piii;
typedef pair<char,int> pci;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> plll;
 


#define pb push_back
 
// order_of_key (k), find_by_order(k)
#define fi first
#define se second
#define input_arr(a,n) for(__typeof (n) i=0; i<n; ++i) {cin>>a[i];}
#define debug_arr(a,n) {{for(__typeof (n) i=0; i<n; ++i) {cout<<a[i]<<" ";}cout<<"\n";}}
#define maxheap priority_queue<ll>
#define minheap priority_queue<ll,vector<ll> ,greater<ll>>
#define initialise(a, x) memset(a, x, sizeof(a))
#define endl '\n'
#define ordered_set tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update>
#define MAX 1000020
#define maxn 200005
#define eps 0.0000001

const ll mod=998244353;
const ll inf=1e18+2;


bool sorter(pair<pii,int> a, pair<pii,int> b)
{
	return a.fi.fi < b.fi.fi;
}

int par[maxn];
int size1[maxn];

int find(int x)
{
	if(par[x]==x) return par[x];
	return par[x]=find(par[x]);
}
void merge(int x,int y)
{
	int parx=find(x);
	int pary=find(y);

	if(pary==parx) return;

	if(size1[parx]>=size1[pary])
	{
		size1[parx]+=size1[pary];
		par[pary]=parx;
		return;
	}
	size1[pary]+=size1[parx];
	par[parx]=pary;
}


signed main()
{

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	// freopen("input.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);

	for(int i=0;i<maxn;i++) {par[i]=i;size1[i]=1;}

	int n;
	cin>>n;

	std::vector<pair<pii,int> > v1;
	std::vector<pair<pii,int> > v2;

	for(int i=0;i<n;i++)
	{
		int l,r;
		cin>>l>>r;
		v1.pb({{l,r},i});
		v2.pb({{-l,-r},i});
	}

	sort(v1.begin(), v1.end(), sorter);
	sort(v2.begin(), v2.end(), sorter);

	int ans[n];
	initialise(ans,0);

	ordered_set st1,st2;

	st1.insert({v1[0].fi.se,v1[0].se});

	for(int i=1;i<n;i++)
	{
		pii top=*(st1.find_by_order(0));

		if(top.fi < v1[i].fi.se)
		{
			merge(top.se,v1[i].se);

			int how=st1.order_of_key({v1[i].fi.se, v1[i].se});
			while(how>1)
			{
				top=*(st1.find_by_order(1));
				merge(top.se,v1[i].se);
				st1.erase(top);
				how--;
			}
		}
		else
			st1.insert({v1[i].fi.se, v1[i].se});
	}

	st2.insert({v2[0].fi.se,v2[0].se});

	for(int i=1;i<n;i++)
	{
		pii top=*(st2.find_by_order(0));

		if(top.fi < v2[i].fi.se)
		{
			merge(top.se,v2[i].se);

			int how=st2.order_of_key({v2[i].fi.se, v2[i].se});
			while(how>1)
			{
				top=*(st2.find_by_order(1));
				merge(top.se,v2[i].se);
				st2.erase(top);
				how--;
			}
		}
		else
			st2.insert({v2[i].fi.se, v2[i].se});
	}

	for(int i=0;i<n;i++)
	{
		cout<<size1[find(i)]<<'\n';
	}


	
	
	

	return 0;
}

Measured memory_bytes: 16324