//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES

#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <functional>
#include <utility>
#include <tuple>
#include <vector>
#include <string>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <iterator>
#include <bitset>
#include <complex>
#include <limits>
#include <random>
#include<fstream>
#include<array>


using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;

const double EPS = 1e-9;

struct UnionFind
{
	vector<int> parent;
	vector<int> rank;

	UnionFind(int N) :parent(N, 0), rank(N, 0)
	{
		rep(i, 0, N)parent[i] = i;
	}

	int find(int x)
	{
		if (parent[x] == x)return x;
		else return parent[x] = find(parent[x]);
	}

	void unite(int x, int y)
	{
		x = find(x);
		y = find(y);

		if (x == y)return;

		if (rank[x] < rank[y])parent[x] = y;
		else {
			parent[y] = x;
			if (rank[x] == rank[y])rank[x]++;
		}
	}

	bool same(int x, int y)
	{
		return find(x) == find(y);
	}
};

struct BIT //0-indexed
{
	vector<int> node;
	int mn;

	BIT(int mn)
	{
		this->mn = mn;
		node.resize(mn + 1, 0);
	}

	void add(int i, int x)
	{
		i++;
		while (i <= mn)
		{
			node[i] += x;
			i += (i&-i);
		}
	}

	int sum(int i)
	{
		i++;
		int res = 0;
		while (i > 0)
		{
			res += node[i];
			i -= (i&-i);
		}
		return res;
	}

	//k:0-indexed
	int get(long long k) {
		++k;
		int res = 0;
		int N = 1; while (N < (int)node.size()) N *= 2;

		for (int i = N / 2; i > 0; i /= 2) {
			if (res + i < (int)node.size() && node[res + i] < k) {
				k = k - node[res + i];
				res = res + i;
			}
		}
		return res;
	}
};

signed main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N;
	cin >> N;

	vector<pii> P(N);
	
	rep(i, 0, N)
	{
		cin >> P[i].first >> P[i].second;
		P[i].first--, P[i].second--;
	}

	vector<pii> OP = P;
	sort(all(P));

	UnionFind uf(N);
	set<int> vset;
	vector<int> ANS(N, 1);
	rep(i, 0, N)
	{
		if (vset.empty() || *vset.begin() > P[i].second)
		{
			vset.insert(P[i].second);
			continue;
		}
		int v = *vset.begin();
		while (!vset.empty() && *vset.begin() < P[i].second)
		{
			int t = *vset.begin();
			int l = ANS[uf.find(t)], r = ANS[uf.find(P[i].second)];
			uf.unite(t, P[i].second);
			ANS[uf.find(t)] = l + r;
			vset.erase(vset.begin());
		}
		vset.insert(v);
	}

	rep(i, 0, N)
	{
		cout << ANS[uf.find(OP[i].second)] << endl;
	}

	return 0;
}


Measured memory_bytes: 16052