#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include "atcoder/dsu.hpp"
using namespace atcoder;
using namespace std;
template<typename T1, typename T2> inline void chkmin(T1 &a, T2 b) {if (a > b) a = b;}
template<typename T1, typename T2> inline void chkmax(T1 &a, T2 b) {if (a < b) a = b;}
#define files(FILENAME) read(FILENAME); write(FILENAME)
#define read(FILENAME) freopen((FILENAME + ".in").c_str(), "r", stdin)
#define write(FILENAME) freopen((FILENAME + ".out").c_str(), "w", stdout)
#define all(c) (c).begin(), (c).end()
#define sz(c) (int)(c).size()
#define left left228
#define right right228
#define y1 y1228
#define mp make_pair
#define pb push_back
#define y2 y2228
#define rank rank228
using ll = long long;
using ld = long double; 
const string FILENAME = "input";
const int MAXN = 200228;


int n;
int x[MAXN], y[MAXN];
int val[MAXN];
int who[MAXN];
int ans[MAXN];
dsu kek;
int ss = 1;



struct node
{
    bool onecomp = true;
    int who = -1;
    int sz = 0;
    node(){}
};


node operator +(const node &a, const node &b) {
    if (a.sz == 0) {
        return b;
    }
    if (b.sz == 0) {
        return a;
    }
    node c;
    c.sz = a.sz + b.sz;
    if (a.onecomp && b.onecomp) {
        if (kek.leader(a.who) == kek.leader(b.who)) {
            c.who = kek.leader(a.who);
            c.onecomp = true;
            return c;
        }
    }
    c.who = -1;
    c.onecomp = false;
    return c;
}


node d[MAXN * 4];


void change(int i, int who) {
    i += ss - 1;
    d[i].who = who;
    d[i].onecomp = true;
    d[i].sz = 1;
    while (i >> 1 > 0) {
        i >>= 1;
        d[i] = d[i * 2] + d[i * 2 + 1];
    }
}


void merges(int v, int vl, int vr, int l, int r, int x) {
    if (l > r) {
        return;
    }
    if (d[v].sz == 0) {
        return;
    }
    if (vl > r || vr < l) {
        return;
    }
    if (l <= vl && vr <= r) {
        if (d[v].onecomp) {
            kek.merge(d[v].who, x);
            return;
        } else {
            merges(v * 2, vl, (vl + vr) / 2, l, r, x);
            merges(v * 2 + 1, (vl + vr) / 2 + 1, vr, l, r, x);
            d[v] = d[v * 2] + d[v * 2 + 1];
        }
        return;
    }
    merges(v * 2, vl, (vl + vr) / 2, l, r, x);
    merges(v * 2 + 1, (vl + vr) / 2 + 1, vr, l, r, x);
    d[v] = d[v * 2] + d[v * 2 + 1];
}

int main() {
  	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	//read(FILENAME);
    cin >> n;
    kek = dsu(n);
    vector<pair<int, int> > str;
    for (int i = 0; i < n; i++) {
        cin >> x[i] >> y[i];
        str.pb(mp(x[i], i));
    }
    sort(all(str));
    for (int i = 0; i < n; i++) {
        val[i] = y[str[i].second];
        who[i] = str[i].second;
    }
    while (ss < n) {
        ss <<= 1;
    }
    {
        for (int i = 0; i < 2 * ss; i++) {
            d[i] = node();
        }
        for (int i = 0; i < n; i++) {
            merges(1, 1, ss, 1, val[i] - 1, i);
            change(val[i], i);
        }   
        for (int i = 0; i < 2 * ss; i++) {
            d[i] = node();
        }
        for (int i = n - 1; i >= 0; i--) {
            merges(1, 1, ss, val[i] + 1, n, i);
            change(val[i], i);
        } 
    }
    for (int i = 0; i < n; i++) {
        ans[who[i]] = kek.size(i);
    }
    for (int i = 0; i < n; i++) {
        cout << ans[i] << '\n';
    }
   	return 0;
}

Measured memory_bytes: 18904