/// kazuki08
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
#define ar array
//#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
    return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
    o<<"{";
    for(const T& v:vc) o<<v<<",";
    o<<"}";
    return o;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

struct UnionFindTree{
    vector<int>par,sz;
    UnionFindTree(int n){
        par.resize(n);
        sz.resize(n);
        for(int i=0;i<n;i++){
            par[i]=i;
            sz[i]=1;
        }
    }
    int find(int x){
        return x==par[x]?x:par[x]=find(par[x]);
    }
    void unite(int x,int y){
        x=find(x);y=find(y);
        if(x==y)return;
        if(sz[x]<sz[y])swap(x,y);
        sz[x]+=sz[y];
        par[y]=x;
    }
    bool Same(int x,int y){
        return find(x)==find(y);
    }
    int size(int x){
        return sz[find(x)];
    }
};

int n;
int ans[201010];

signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
  
  cin >> n;
  int id[n+1]={0};
  UnionFindTree uf(n+10);
  vector<pair<pi,int>> v;
  for(int i=1;i<=n;i++){
    int x,y;
    cin >> x >> y;
    id[y]=i;
    v.pb({{x,y},i});
  }
  set<int> s;
  sort(all(v));
  for(int i=0;i<n;i++){
    if(s.size()){
      auto it = s.lower_bound(v[i].fs.sc);
      if(it!=s.begin()){
        it--;
        if(*it<v[i].fs.sc){
          uf.unite(id[*it],v[i].sc);
        }
      }
      it = s.begin();
      if(*it<v[i].fs.sc){
        uf.unite(id[*it],v[i].sc);
      }
    }
    s.insert(v[i].fs.sc);
  }
  s.clear();
  reverse(all(v));
  for(int i=0;i<n;i++){
    if(s.size()){
      auto it = s.lower_bound(v[i].fs.sc);
      if(it!=s.end()){
        if(*it>v[i].fs.sc){
          uf.unite(id[*it],v[i].sc);
        }
      }
      it = s.end();
      it--;
      if(*it>v[i].fs.sc){
        uf.unite(id[*it],v[i].sc);
      }
    }
    s.insert(v[i].fs.sc);
  }
  for(int i=0;i<v.size();i++){
    id[v[i].fs.fs]=v[i].sc;
    swap(v[i].fs.fs,v[i].fs.sc);
  }
  sort(all(v));
  s.clear();
  for(int i=0;i<n;i++){
    if(s.size()){
      auto it = s.lower_bound(v[i].fs.sc);
      if(it!=s.begin()){
        it--;
        if(*it<v[i].fs.sc){
          uf.unite(id[*it],v[i].sc);
        }
      }
      it = s.begin();
      if(*it<v[i].fs.sc){
        uf.unite(id[*it],v[i].sc);
      }
    }
    s.insert(v[i].fs.sc);
  }
  s.clear();
  reverse(all(v));
  for(int i=0;i<n;i++){
    if(s.size()){
      auto it = s.lower_bound(v[i].fs.sc);
      if(it!=s.end()){
        if(*it>v[i].fs.sc){
          uf.unite(id[*it],v[i].sc);
        }
      }
      it = s.end();
      it--;
      if(*it>v[i].fs.sc){
        uf.unite(id[*it],v[i].sc);
      }
    }
    s.insert(v[i].fs.sc);
  }

  for(int i=1;i<=n;i++){
    cout << uf.size(i) << endl;
  }

return 0;
}
///....


Measured memory_bytes: 22144