#include <bits/stdc++.h>
using namespace std;

#define pii pair<int, int>

const int maxN = 2e5 + 10;

int n;
int pa[maxN + 1], mx[maxN + 1], sz[maxN + 1];
int a[maxN + 1], ans[maxN + 1], id[maxN + 1];

inline int find(int x) { return pa[x] == x ? x : pa[x] = find(pa[x]); }

inline void merge(int x, int y)
{
	x = find(x), y = find(y);
	if(x == y) return;
	pa[x] = y;
	sz[y] += sz[x]; mx[y] = max(mx[y], mx[x]);
}

int main()
{
	scanf("%d", &n);
	for(int i = 1; i <= n; i++)
	{
		int x, y;
		scanf("%d %d", &x, &y);
		a[x] = y; id[i] = x;
	}

	for(int i = 1; i <= n; i++) pa[i] = i, mx[i] = a[i], sz[i] = 1;

	priority_queue<pii> q;
	for(int i = n; i >= 1; i--)
	{
		while(!q.empty() && a[i] < q.top().first)
		{
			merge(i, q.top().second);
			q.pop();
		}
		int p = find(i);
		q.push( pii(mx[p], p) );
	}

	for(int i = 1; i <= n; i++) printf("%d\n", sz[ find(id[i]) ]);
	return 0;
}
