#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define per(i, a, b) for (int i = a; i >= b; i--)
using namespace std;

typedef unsigned long long ull;
typedef pair <int, int> pii;
typedef long long ll;

template <typename _T>
inline void read(_T &f) {
    f = 0; _T fu = 1; char c = getchar();
    while (c < '0' || c > '9') { if (c == '-') { fu = -1; } c = getchar(); }
    while (c >= '0' && c <= '9') { f = (f << 3) + (f << 1) + (c & 15); c = getchar(); }
    f *= fu;
}

template <typename T>
void print(T x) {
    if (x < 0) putchar('-'), x = -x;
    if (x < 10) putchar(x + 48);
    else print(x / 10), putchar(x % 10 + 48);
}

template <typename T>
void print(T x, char t) {
    print(x); putchar(t);
}

const int N = 2e5 + 5;

int a[N], b[N], ida[N], idb[N], vis[N], ans[N];
int n, cnt;

bool cmpa(int x, int y) { return a[x] < a[y]; }
bool cmpb(int x, int y) { return b[x] < b[y]; }

int main() {
    read(n);
    for (int i = 1; i <= n; i++) read(a[i]), read(b[i]), ida[i] = idb[i] = i;
    sort(ida + 1, ida + n + 1, cmpa); sort(idb + 1, idb + n + 1, cmpb);
    int las = 0;
    for (int i = 1; i <= n; i++) {
        if (!vis[ida[i]]) vis[ida[i]] = 1, ++cnt;
        if (!vis[idb[n - i + 1]]) vis[idb[n - i + 1]] = 1, ++cnt;
        if (cnt == i) {
            for (int j = las + 1; j <= i; j++) ans[ida[j]] = i - las;
            las = i;
        }
    }
    for (int i = 1; i <= n; i++) print(ans[i], '\n');
    return 0;
}