#include <bits/stdc++.h>
using namespace std;
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; }

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }



struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }
    
    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};


template <class Abel> struct BIT {
    Abel UNITY_SUM = 0;
    vector<Abel> dat;
    
    // [0, n)
    BIT(int n, Abel unity = 0) : UNITY_SUM(unity), dat(n, unity) { }
    void init(int n) {
        dat.assign(n, UNITY_SUM);
    }
    
    // a is 0-indexed
    inline void add(int a, Abel x) {
        for (int i = a; i < (int)dat.size(); i |= i + 1)
            dat[i] = dat[i] + x;
    }
    
    // [0, a), a is 0-indexed
    inline Abel sum(int a) {
        Abel res = UNITY_SUM;
        for (int i = a - 1; i >= 0; i = (i & (i + 1)) - 1)
            res = res + dat[i];
        return res;
    }
    
    // [a, b), a and b are 0-indexed
    inline Abel sum(int a, int b) {
        return sum(b) - sum(a);
    }
    
    // debug
    void print() {
        for (int i = 0; i < (int)dat.size(); ++i)
            cout << sum(i, i + 1) << ",";
        cout << endl;
    }
};

ostream& operator << (ostream& s, UnionFind uf) {
    map<int, vector<int> > res;
    for (int i = 0; i < uf.par.size(); ++i) {
        int r = uf.root(i);
        res[r].push_back(i);
    }
    for (map<int, vector<int> >::iterator it = res.begin(); it != res.end(); ++it) {
        s << endl;
        for (int j = 0; j < (int)it->second.size(); ++j) {
            s << it->second[j] << ", ";
        }
    }
    return s << endl;
}

using pint = pair<int,int>;
using item = pair<pint,int>;

bool operator < (pint a, pint b) {
    return a.second > b.second;
}

int main() {
    int N;
    cin >> N;
    vector<item> v(N);
    for (int i = 0; i < N; ++i) {
        int x, y;
        cin >> x >> y;
        --x, --y;
        v[i] = item(pint(x, y), i);
    }
    sort(v.begin(), v.end(), [&](item a, item b) {
        return a.first.first > b.first.first;
    });

    //COUT(v);

    UnionFind uf(N);
    set<pint> se;
    for (auto p : v) {
        int x = p.first.first, y = p.first.second;
        if (se.empty()) {
            se.insert(pint(x, y));
            continue;
        }
        auto hp = *se.begin();
        int hx = hp.first, hy = hp.second;

        if (hy < y) {
            se.insert(pint(x, y));
        }
        else {
            uf.merge(x, hx);
            auto it = se.begin();
            ++it;
            for (; it != se.end();) {
                auto hp = *it;
                hx = hp.first, hy = hp.second;
                if (hy > y) {
                    it = se.erase(it);
                    uf.merge(x, hx);
                }
                else break;
            }
        }

        //COUT("------------");COUT(p);COUT(se); COUT(uf);
    }
    vector<int> res(N);
    for (auto p : v) {
        int x = p.first.first;
        int ind = p.second;
        res[ind] = uf.size(x);
    }
    for (auto v : res) cout << v << endl;
}

















Measured memory_bytes: 7304