#include<bits/stdc++.h>
using namespace std;
const int N = 2e5+100;
typedef pair<int,int> pii;
#define fr(i,a,b) for(int i = a;i <= b; ++i)
#define nfr(i,a,b) for(int i = a;i >= b; --i)
#define pb push_back

int n;

struct point{
   int x,y,id;
   bool operator <(const point &b) const {
      return x < b.x;
   }
}p[N];

int f[N],cnt[N];
inline int find(int x){
   return (f[x] == x) ? x : f[x] = find(f[x]);
}

inline bool merge(int x,int y){
   int f1 = find(x),f2 = find(y);
   if(f1 == f2)return false;
   cnt[f1] += cnt[f2]; cnt[f2] = 0;
   f[f2] = f1;
   return true;
}

int ans[N];
set<pii> s1;

int main(){
   scanf("%d",&n);
   fr(i,1,n){
      scanf("%d%d",&p[i].x,&p[i].y); p[i].id = i;
   }
   sort(p+1,p+n+1);
   fr(i,1,n)cnt[i] = 1,f[i] = i;

   s1.insert(pii(p[1].y,p[1].x));
   fr(i,2,n){
      vector<pii> v1;
      for(set<pii>::iterator k = s1.begin();k != s1.end(); ++k){
         pii j = *k;
         if(j.first > p[i].y)break;
         v1.pb(j);
         merge(j.second,i);
      }
      if(v1.empty())s1.insert(pii(p[i].y,p[i].x));
      else {
         fr(i,1,(int)v1.size()-1)s1.erase(v1[i]);
      }
   }

   fr(i,1,n)ans[p[i].id] = cnt[find(i)];
   fr(i,1,n)printf("%d\n",ans[i]);
   return 0;
}
