#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N = 2e5 + 5;
int memo[N];
vector <int> a[N];

bool ch(int d1, int h1, int d2, int h2) {
	return d1 < d2 && h1 > h2;
}

int f(int n) {
	if (memo[n] != -1) return memo[n];
	int res = 1;
	for (int x : a[n]) {
		res = max(res, f(x) + 1);
	}
	return res;
}

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	int d[n], h[n];
	for (int i = 0; i < n; ++i) cin >> d[i] >> h[i];
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < n; ++j) {
			if (ch(d[j], h[j], d[i], h[i])) a[i].push_back(j);
		}
	}
	memset(memo, -1, sizeof(memo));
	for (int i = 0; i < n; ++i) cout << f(i) << '\n';
	return 0;
}