/*----------------
     Smit Patel
     DA-IICT
----------------*/
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// #define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
// #define ordered_set tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define ins insert
#define fori(i,a,n) for(ll i=a; i<n; i++)
#define ford(i,a,n) for(ll i=a; i>n; i--)
#define clr(a,b) memset(a,b,sizeof(a))
#define sp fixed<<setprecision
#define deb(x) cout<<#x<<" : "<<x<<endl;
#define debug(x,y) cout<<#x<<" : "<<x<<"  "<<#y<<" : "<<y<<endl;
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define bp __builtin_popcount
#define mod 1000000007
#define eps 1e-6
#define infi 1000000002
#define infll 1e18+5
#define N 200005
#define LN 23

typedef long double ld;
typedef long long ll;
typedef map<ll,ll> mll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef set<ll> sll;

ll choose(ll n,ll k);
bool isprime(ll n);
ll power(ll x,ll y,ll p);
ll power(ll x,ll y);
ll gcd(ll a,ll b);

struct DSU
{
	ll connected;
	vector<ll> par, sz;

	void init(ll n)
	{
		par = sz = vector<ll> (n + 1, 0);
		for(ll i = 1; i <= n; i++)
			par[i] = i, sz[i] = 1;
		connected = n;
	}

	ll getPar(ll u)
	{
		while(u != par[u])
		{
			par[u] = par[par[u]];
			u = par[u];
		}
		return u;
	}

	ll getSize(ll u)
	{
		return sz[getPar(u)];
	}

	void unite(ll u, ll v)
	{
		ll par1 = getPar(u), par2 = getPar(v);

		if(par1 == par2)
			return;

		connected--;

		if(par1 < par2)
			swap(par1, par2);

		sz[par2] += sz[par1];
		sz[par1] = 0;
		par[par1] = par[par2];
	}
};

DSU ds;

int main()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ll n;
  cin>>n;
  pair<pll,ll> p[n];
  fori(i,0,n)
  {
    cin>>p[i].ff.ff>>p[i].ff.ss;
    p[i].ss=i;
  }
  sort(p,p+n);
  vll ans(n,0);
  ds.init(n);

  set<ll> st;
  fori(i,0,n)
  {
    ll tmp = p[i].ff.ss;
    if(st.empty())
    {
      st.ins(tmp);
      continue;
    }
    auto it=st.begin();
    if(*it>tmp)
    {
      st.ins(tmp);
      continue;
    }
    ll root = ds.getPar(*it);
    vll rem;
    it++;
    while(it!=st.end())
    {
      if(*it>tmp) break;
      ds.unite(root,*it);
      rem.pb(*it);
      it++;
    }
    for(auto tt:rem)
    {
      st.erase(tt);
    }
    ds.unite(tmp,root);
  }
  fori(i,0,n)
  {
    ans[p[i].ss] = ds.sz[ds.getPar(p[i].ff.ss)];
  }
  fori(i,0,n) cout<<ans[i]<<endl;
  return 0;
}

ll gcd(ll a,ll b)
{
  if(b==0)
    return a;
  return gcd(b,a%b);
}

ll choose(ll n,ll k)
{
  if(k==0)
    return 1;
  return (n* choose(n-1,k-1))/k;
}

bool isprime(ll n)
{
  for(ll i=2;i*i<=n;i++)
  {
    if(n%i==0)
      return false;
  }
  return true;
}

ll power(ll x,ll y,ll p)
{
  ll res=1;
  x=x%p;
  while(y>0)
  {
    if(y&1)
      res=(res*x)%p;
    y=y>>1;
    x=(x*x)%p;
  }
  return res;
}

ll power(ll x,ll y)
{
  ll res=1;
  while(y>0)
  {
    if(y&1)
      res=res*x;
    y=y>>1;
    x=x*x;
  }
  return res;
}


Measured memory_bytes: 16228