#include <iostream>
#include <set>
#include <utility>
#include <algorithm>
using namespace std;
int par[200010],sz[200010],x[200010],y[200010],mn[200010];
void init(int n){
	for(int i=0;i<n;i++){
		par[i] = i; sz[i] = 1; mn[i] = y[i];
	}
}

int find(int x){
	if(par[x]==x) return x;
	return par[x] = find(par[x]);
}

void unite(int x, int y){
	x = find(x); y = find(y);
    mn[y] = min(mn[x],mn[y]);
	if(x==y) return;
	if(sz[x]>sz[y]) swap(x,y);
	par[x] = y;
	sz[y] += sz[x];
}

bool same(int x, int y){
	return find(x)==find(y);
}

set<pair<int,int>> s;
pair<pair<int,int>,int> p[200010];
int main(){
    int i,n; cin >> n;
    for(i=0;i<n;i++){
        cin >> x[i] >> y[i]; x[i]--; y[i]--;
        p[i] = {{x[i],y[i]},i};
    }
    init(n);
    sort(p,p + n);
    s.insert({100000000,-1});
    for(i=0;i<n;i++){
        pair<int,int> q = p[i].first;
        pair<int,int> r = {q.second,p[i].second};
        for(auto x:s){
            if(q.second<x.first){
                s.insert(r);
                break;
            }else{
                unite(p[i].second,x.second);
                r = min(r,{mn[find(p[i].second)],find(p[i].second)});
                s.erase(x);
            }
        }
    }
    for(i=0;i<n;i++) cout << sz[find(i)] << endl;
}