#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

template <class T>
class SegTree {
    int n; // number of leaves
    vector<T> data; // vector which has datas
    T def; // init number & 単位元
    function<T(T,T)> operation; // 区間クエリで使う処理
    function<T(T,T)> update; // 点更新で使う処理

    T _query(int a, int b, int k, int l, int r) {
        // [a, b)のクエリ
        // ノードk(区間[l, r)担当)が答える
        if (b <= l || r <= a) return def; // 区間がかぶらなければdef
        if (a <= l && r <= b) return data[k]; // 区間が完全にかぶっていればdata[k]
        else {
            // 一部だけかぶる場合は左右の子に委託する
            T c1 = _query(a, b, 2*k+1, l, (l+r)/2);
            T c2 = _query(a, b, 2*k+2, (l+r)/2, r);
            return operation(c1, c2);
        }
    }

    public:

        SegTree(size_t _n, T _def, function<T(T,T)> _operation, function<T(T,T)> _update) :
            def(_def), operation(_operation), update(_update){
                n = 1;
                while (n < _n) {n *= 2;}
                data = vector<T>(2*n-1, def);
        }

        T query(T a, T b) {return _query(a,b,0,0,n);}

        void change(T i, T x) {
            i += n-1;
            data[i] = update(data[i],x);
            while (i>0) {
                i = (i-1)/2;
                data[i] = operation(data[i*2+1], data[i*2+2]);
            }
        }

        T operator[](int i) {return data[i+n-1];}
};


class union_find {
private:
    vector<ll> par;
    vector<ll> ran;
    vector<ll> m_size;
public:
    union_find(ll n);
    ll find(ll x);
    void unite(ll x, ll y);
    bool same(ll x, ll y);
    ll size(ll x);
};

union_find::union_find(ll n){
    par.resize(n);
    ran.resize(n, 0);
    m_size.resize(n, 1);
    rep(i,n) par[i] = i;
};

ll union_find::find(ll x) {
    if (par[x] == x) return x;
    else return par[x] = find(par[x]);
};

void union_find::unite(ll x, ll y) {
    x = find(x);
    y = find(y);
    if (x == y) return;
    ll t = size(x)+size(y);
    m_size[x] = m_size[y] = t;
    if (ran[x] < ran[y]) {
        par[x] = y;
        //size[y] += size[x];
    } else {
        par[y] = x;
        //ize[x] += size[y];
        if (ran[x]==ran[y]) ran[x]++;
    }
};

ll union_find::size(ll x) {
    if (par[x] == x) return m_size[x];
    return size(par[x] = find(par[x]));
}

bool union_find::same(ll x, ll y) {
    return (find(x) == find(y));
};

typedef tuple<ll, ll, ll> T;
int main(int argc, char const *argv[]) {
    int n; cin>>n;
    vector<T> a;
    union_find uf(n);
    vector<int> id(n+1);
    vector<int> con(n+1);
    rep(i,n) {
        ll x,y; cin>>x>>y;
        id[y] = i;
        a.emplace_back(x,y,i);
    }
    sort(a.begin(), a.end());
    SegTree<ll> lef((size_t)n+1, INF, [](ll a, ll b) { return min(a, b); }, [](ll i, ll x) { return x; });
    SegTree<ll> rig((size_t)n+1, -INF, [](ll a, ll b) { return max(a, b); }, [](ll i, ll x) { return x; });

    rep(i,n) {
        int y = get<1>(a[i]);
        int idx = get<2>(a[i]);
        lef.change(y, i);
        con[i] = idx;
    }

    vector<ll> ans(n);
    for (int i = n-1; i >= 0; --i) {
        int y = get<1>(a[i]);
        int idx = get<2>(a[i]);
        ll mini = lef.query(0, y);
        ll maxi = rig.query(i, n+1);
        /*
        cout << "y = " << y << '\n';
        cout << "mini = " << mini << '\n';
        cout << "maxi = "<< maxi << '\n';
        */
        if (mini != INF) {
            uf.unite(id[y], con[mini]);
            // cout << "unite: " << id[y] << ", " << con[mini] << '\n';
        }
        if (maxi != -INF && maxi > y) {
            uf.unite(id[y], id[maxi]);
            // cout << "unite: " << id[y] << ", " << id[maxi] << '\n';
        }
        lef.change(y, INF);
        rig.change(i, y);
    }

    rep(i,n) ans[i] = uf.size(i);
    for (auto &&e: ans) cout << e << '\n';
    return 0;
}

/*
7

5 7 2 3 6 1 4
5 2 6 7 4 3 1
*/

Measured memory_bytes: 23980