#include "bits/stdc++.h"
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define per(i,a,n) for(int i=n;i>=a;i--)
#define pb push_back
#define mp make_pair
#define FI first
#define SE second
#define maxn 200000
#define mod 1000000007
#define inf 0x3f3f3f3f
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef double db;

int x[maxn+5],y[maxn+5],id[maxn+5];
int fa[maxn+5],sz[maxn+5],mn[maxn+5];

int getfa(int x)
{
    if(fa[x]==x) return x;
    return fa[x]=getfa(fa[x]);
}

int main()
{
    int n; scanf("%d",&n);
    rep(i,1,n) scanf("%d%d",&x[i],&y[i]),id[i]=i;
    sort(id+1,id+n+1,[](int a,int b){return x[a]<x[b];});
    rep(i,1,n) fa[i]=i,mn[i]=i,sz[i]=1;
    stack<int> s;
    rep(I,1,n)
    {
        int i=id[I];
        while(s.size() && y[s.top()]<y[i])
        {
            int j=s.top(); s.pop();
            int fi=getfa(i);
            int fj=getfa(j);
            if(fi!=fj)
            {
                //printf("! %d: %d %d\n",I,i,j);
                if(sz[fi]<sz[fj]) swap(fi,fj);
                sz[fi]+=sz[fj];
                fa[fj]=fi;
                if(y[mn[fi]]>y[mn[fj]]) mn[fi]=mn[fj];
            }
        }
        int x=mn[getfa(i)]; s.push(x);
    }
    rep(i,1,n) printf("%d\n",sz[getfa(i)]);
    return 0;
}