#include<iostream>
#include<cstring>
#include<set>
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=200010;
int n;
int tr[N];
int res[N];
struct node{
    int x;
    int y;
    int id;
    bool operator < (const node&W)const
    {
        if(x!=W.x)
        return x<W.x;
        return  y<W.y;
    }
}q[N];
int p[N];
int sz[N];
int find(int x)
{
    if(p[x]!=x)
        p[x]=find(p[x]);
    return p[x];
}
set<pair<int,int>>s;
set<pair<int,int>>S;
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d%d",&q[i].x,&q[i].y),q[i].id=i,p[i]=i,sz[i]=1;
     sort(q+1,q+n+1);
   for(int i=1;i<=n;i++)
   {
            if(s.empty())
            s.insert({q[i].y,q[i].id});
        auto it=s.lower_bound({q[i].y,0});
        int b=q[i].id;
        b=find(b);
        bool flag=false;
        for(set<pair<int,int>>::iterator x=s.begin();x!=it;x++)
        {
            flag=true;
            int a=x->second;
           a=find(a);
            if(a!=b)
            {
                p[a]=b;
                sz[b]+=sz[a];
              //  break;
            }
        }
        if(!flag)
            s.insert({q[i].y,q[i].id});
   }
    for(int i=1;i<=n;i++)
        printf("%d\n",sz[find(i)]);
    return 0;
}