#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, a, b) for(int i = (a); i <= (b); i++)
#define PER(i, a, b) for(int i = (a); i >= (b); i--)
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define all(S) (S).begin(), (S).end()
#define pb push_back
#define mk make_pair
#define S second
#define F first
typedef long long ll;
typedef long double lf;
typedef pair<int, int> ii;
typedef pair<ii, int> pii;
const int MAX = 2e5+5;
int p[MAX], sz[MAX];

int find(int a) { return (p[a] == a) ? a : p[a] = find(p[a]); }

int main(int argc, char** argv) {
	int N, x, y, u, v;
	int me = (1<<30);
	vector<pii> num;
	scanf("%d", &N);
	REP(i, 1, N) {
	    scanf("%d%d", &x, &y);
	    num.pb(mk(mk(x, y), i));
	}
	rep(i, 1, MAX) sz[i] = 1;
    rep(i, 1, MAX) p[i] = i;
	sort(all(num));
	for(int i = 0, j = N; i < N; i++, j--) {
	    me = min(me, num[i].F.S);
	    if(me == j || i == N-1) continue;
	    if((u = find(num[i].S)) != (v = find(num[i+1].S))) {
	        p[u] = v;
	        sz[u] = sz[v] = (sz[u]+sz[v]);
	    }
	}
	REP(i, 1, N) printf("%d\n", sz[find(i)]);
	return 0;
}
