#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <limits>
#include <list>
#include <numeric>
#include <queue>
#include <stack>
#include <utility>
#include <array>
#include <random>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <assert.h>
using namespace std;
typedef long long ll;
#define dump(x) cerr << #x << " = " << (x) << " [" << __LINE__ << ":" << __FUNCTION__ << "] " << endl;
// vector出力
template < typename T >
ostream& operator<<(ostream& os, vector< T >& v) {
    os << "{";
    for (int i = 0; i < (int)v.size(); i++) {
        os << v[i] << (i < v.size() - 1 ? ", " : "");
    }
    os << "}";
    return os;
}
// pair出力
template < typename T, typename U >
ostream& operator<<(ostream& os, pair< T, U >& p) {
    return os << "(" << p.first << ", " << p.second << ")";
}
// map出力
template < typename T, typename U >
ostream& operator<<(ostream& os, map< T, U >& map_var) {
    os << "{";
    for (auto itr = map_var.begin(); itr != map_var.end(); itr++) {
        os << "(" << itr->first << ", " << itr->second << ")";
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
// set 出力
template < typename T >
ostream& operator<<(ostream& os, set< T >& set_var) {
    os << "{";
    for (auto itr = set_var.begin(); itr != set_var.end(); itr++) {
        os << *itr;
        ++itr;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
#pragma endregion

/////////////////////////////////////////

// UnionFind
class UnionFind {
private:
    vector<int> par;
public:
    UnionFind(int n) {
        par.resize(n, -1);
    }

    int root(int x) {
        if (par[x] < 0) return x;
        return par[x] = root(par[x]);
    }

    bool unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return false;
        if (size(rx) < size(ry)) swap(rx, ry);
        par[rx] += par[ry];
        par[ry] = rx;
        return true;
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }

    int size(int x) {
        return -par[root(x)];
    }
};

int main() {
    int n;cin >> n;
    vector<pair<pair<int,int>,int>> p(n);
    UnionFind uf(n);
    set<pair<int,int>> st;
    st.insert({-1,-1});
    for (int i = 0; i < n; i++) {
        int x,y;cin >> x >> y;
        p[i].first.first = x-1;
        p[i].first.second = y-1;
        p[i].second = i;
    }
    sort(p.rbegin(), p.rend());
    for (int i = 0; i < n; i++) {
        auto t = st.rbegin();
        if (t->first > p[i].first.second) {
            auto t2 = st.lower_bound({p[i].first.second,0});
            while(t2->first < t->first) {
                uf.unite(t2->second,t->second);
                t2 = st.erase(t2);
            }
            uf.unite(p[i].second,t->second);
        }
        else {
            st.insert({p[i].first.second,p[i].second});
        }
    }
    reverse(p.begin(), p.end());
    st.clear();
    st.insert({n,-1});
    for (int i = 0; i < n; i++) {
        auto t = st.begin();
        if (t->first < p[i].first.second) {
            if (t->first != n) uf.unite(t->second,p[i].second);
            t++;
            while (t != st.end() && t->first < p[i].first.second) {
                uf.unite(p[i].second,t->second);
                //cout << p[i].second << "-" << t->second << endl;
                t = st.erase(t);
            }
        }
        else {
            st.insert({p[i].first.second,p[i].second});
        }
    }
    for (int i = 0; i < n; i++) {
        cout << uf.size(i) << endl;
    }
    return 0;
}

/////////////////////////////////////////

Measured memory_bytes: 11184