#include <bits/stdc++.h>
using namespace std;
using ll = long long;

const int MAX_N = 2e5+10;

struct p
{
    int x, y, idx;
    bool operator<(const p& o) const
    {
        return x < o.x;
    }
};

int N;
p v[MAX_N];
int sz[MAX_N];

void solve()
{
	sort(v+1,v+N+1);
	set<int> unused, comp;
	for(int i=1;i<=N;++i) unused.insert(i);
	int mi = N+1;
	for(int i=1;i<=N;++i){
		int y=v[i].y;
		mi = min(mi, y);
		comp.insert(v[i].idx);
		unused.erase(y);
		if(unused.lower_bound(mi) == unused.end()){
			const int m = comp.size();
			for(int x : comp) sz[x] = m;
			comp.clear();
			mi = N+1;
		}
	}
	for(int i=1;i<=N;++i) cout<<sz[i]<<'\n';
}

int main()
{
	cin >> N;
	for(int i=1;i<=N;++i){
	    cin >> v[i].x >> v[i].y;
	    v[i].idx=i;
	}
	solve();
	return 0;
}