#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <cmath>
#include <set>
#include <stack>
#include <queue>
#include <numeric>
#include <deque>
#include <cstring>
#include <iterator>
#include <map>
#include <cstdlib>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <complex>
#include <bitset>
#include <chrono>
#include <random>
#include <assert.h>
#include <array>

using namespace std;

template<typename M, typename N>
istream& operator>>(istream&is, pair<M,N> & p){is >> p.first >> p.second; return is;}
template<typename M>
istream& operator>>(istream&is, vector<M> & v){for(auto &it:v) is >> it; return is; }
template<typename M>
istream& operator>>(istream&is, vector<vector<M>> & v){for(auto &it:v) is >> it; return is; }
template<typename M, typename N>
ostream& operator<<(ostream&os, const pair<M,N> &p){os << p.fi << ' ' << p.se << '\n';return os;}
template<typename M>
ostream& operator<<(ostream&os, const vector<M> &v){for(auto it: v)os << it << ' ';cout << '\n';return os;}
template<typename M>
ostream& operator<<(ostream&os, const vector<vector<M>> &v){for(auto it: v)os << it;return os;}

#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mn(x) *min_element((x).begin(),(x).end())
#define mx(x) *max_element((x).begin(),(x).end())
#define acc(x) accumulate((x).begin(),(x).end(),0ll)
#define eb emplace_back
#define el '\n'
typedef  long long  ll;
typedef  unsigned long long  ull;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<pll> vpll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<string> vs;

const ld pi=acos(-1);
const ll inf=(ll)1e9+10;
//const int mod=1000000007;
const int mod=998244353;

int n,m,k;
const int N=2e5+10;


vi P(N);
vi S(N);
void ms(int u){
    P[u]=u;
    S[u]=1;
}
int fs(int u){
    return P[u]=u==P[u]?u:fs(P[u]);
}
void me(int u, int v){
    u=fs(u);
    v=fs(v);
    if(u!=v){
        if(S[u]>S[v])
            swap(u,v);
        P[u]=v;
        S[v]+=S[u];
    }
    
}

int main()
{   ios_base::sync_with_stdio(false);cin.tie(NULL);
    cin >> n;
    vector<array<int,3>> v(n);
    vector<vector<pii>> vv;
    for(int i=0; i<n; i++){
        cin >> v[i][0] >> v[i][1];
        v[i][2]=i+1;
    }
    for(int i=1; i<N; i++){
        ms(i);
    }
    stack<pii> st;
    sort(all(v));
    int id=0;
    for(int i=0; i<n; i++){
        if(st.empty()){
            st.push({v[i][1],v[i][2]});
        }
        else{
            auto f=st.top();
            if(v[i][1]<f.fi){
                st.push({v[i][1],v[i][2]});
            }
            else{
                me(f.se,v[i][2]);
                while(!st.empty() && st.top().fi<v[i][1]){
                    auto ff=st.top();
                    st.pop();
                    me(f.se, ff.se);
                }
                st.push(f);
            }
        }
    }
    for(int i=1; i<=n; i++){
        cout << S[fs(i)] << el;
    }
    return 0;
}








Measured memory_bytes: 7248