//#include<cstdio>
//#include<cassert>
//#include<iostream>
//#include<cstring>
//#include<algorithm>
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define MAX ((int)2e9 + 5)
#define MAXP ((int)1e5)
#define MAXL ((ll)1e18 + 5)
#define MAX_X ((ll)1e5 + 2)
#define pi acos(-1)
#define M ((int)1e6 + 7)
#define MOD ((int)998244353 + 0)
#define MOD1 ((int)998244353 + 0)
#define BAS ((int)1e6 + 3)
#define BAS1 ((int)2e5 + 3)
#define NN ((int)1e5 + 5)
#define N ((int)2e5 + 5)
#define eps (0)
#define fastio ios_base::sync_with_stdio(false),cin.tie(NULL)
#define logn 10
#define endl "\n"
#define mp make_pair
#define BUCK 105
#define LEF (idx<<1)
#define RIG ((idx<<1)|1)
//#define int ll


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef unsigned long long ull;

/*fast io
ios_base::sync_with_stdio(false);
cin.tie(NULL);
*/




typedef tree < int,  null_type,  less < int >,  rb_tree_tag,  tree_order_statistics_node_update > o_set;
//typedef tree < pair < int, int >,  null_type,  less < pair < int, int > >,  rb_tree_tag,  tree_order_statistics_node_update > o_set;
/// o_set s;
/// s.order_of_key(k) : Number of items strictly smaller than k .
/// *(s.find_by_order(k)) : K-th element in a set (counting from zero).

struct info{
    int x , y;
}arr[N];
bool cmpx(info a , info b)
{
    return a.x<b.x;
}

bool cmpy(info a , info b)
{
    return a.y<b.y;
}

int par[N] , idx[N] , idy[N] , cnt[N];

pair < int , int > trr[N<<2];

void update(int idx , int b , int e , int i , int x)
{
    if(i<b || i>e) return;
    if(b == e){
        trr[idx] = {x,i};
        return;
    }

    int mid = (b+e)>>1;
    update(LEF,b,mid,i,x);
    update(RIG,mid+1,e,i,x);
    trr[idx] = trr[RIG];
    if(trr[LEF] > trr[idx]) trr[idx] = trr[LEF];
}

pair < int , int > get(int idx , int b , int e , int i , int j )
{
    if(j<b || e<i || i>j) return {0,0};
    if(i<=b && j>=e) return trr[idx];
    int mid = (b+e)>>1;
    pair < int , int > ans = get(RIG,mid+1,e,i,j) , tmp = get(LEF,b,mid,i,j);
    if(ans >= tmp) return ans;
    return tmp;
}

int findpar(int a)
{
    if(a == par[a]) return a;
    return par[a] = findpar(par[a]);
}

void connect(int a , int b)
{
    if(findpar(a) != findpar(b)){
        a = findpar(a);
        b = findpar(b);
        cnt[a] += cnt[b];
        par[b] = a;
    }
}

int main()
{
    fastio;
    int n ;
    cin>>n;
    for(int i = 1 ; i<=n ; i++){
        par[i] = i;
        cnt[i] = 1;
        cin>>arr[i].x>>arr[i].y;
        idx[arr[i].x] = i;
        idy[arr[i].y] = i;
    }

    sort(arr+1,arr+n+1,cmpx);

    for(int i = 1 ; i<=n ; i++){
        int cur = 1;
        while(cur < arr[i].y){
            pair < int , int > p = get(1,1,n,cur,arr[i].y-1);
            int tmp = p.second;
//        cout<<i<<" "<<tmp<<endl;
            if(p.first != 0){
                connect(idy[tmp],idx[arr[i].x]);
                cur = tmp + 1;
            }
            else break;
        }
        update(1,1,n,arr[i].y,arr[i].x);
    }

//    sort(arr+1,arr+n+1,cmpy);
//    memset(trr,0,sizeof trr);
//    for(int i = 1 ; i<=n ; i++){
//        int tmp = get(1,1,n,1,arr[i].x-1);
////        cout<<i<<" "<<tmp<<endl;
//        if(tmp != 0) connect(idy[tmp],idx[arr[i].x]);
//        update(1,1,n,arr[i].x,arr[i].y);
//    }
    for(int i = 1 ; i<=n ; i++){
        cout<<cnt[findpar(i)]<<endl;
    }
    return 0;
}


Measured memory_bytes: 12460