#line 1 "main_a.cpp"
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstdint>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <chrono>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <utility>
#include <limits>
#include <list>
#include <type_traits>

/* template start */

using i64=std::int_fast64_t;
using u64=std::uint_fast64_t;
 
#define rep(i, a, b) for (i64 i = (a); (i) < (b); (i)++)
#define all(i) i.begin(), i.end()

#ifdef LOCAL
#define debug(...) std::cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out(){std::cerr<<std::endl;}

template<typename Head,typename... Tail>
void debug_out(Head h,Tail... t){
  std::cerr<<" "<<h;
  if(sizeof...(t)>0)std::cout<<" :";
  debug_out(t...);
}
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}

template<typename Num>
constexpr Num mypow(Num a, u64 b,Num id=1) {
  if(b==0)return id;
  Num x = id;
  while (b > 0) {
    if(b & 1)x*=a;
    a*=a;
    b >>= 1;
  }
  return x;
}

/* template end */

#line 2 "/home/imperi/cp-library/lib/UnionFind/UnionFind.hpp"

#include <cstddef>
#line 6 "/home/imperi/cp-library/lib/UnionFind/UnionFind.hpp"

class UnionFind {
 public:
  using size_t = std::size_t;

 private:
  std::vector<size_t> par, sz;
  size_t group;

 public:
  UnionFind(size_t n = 0) : par(n, 0), sz(n, 1), group(n) {
    std::iota(par.begin(), par.end(), 0);
  }

  size_t root(size_t n) {
    if (par[n] == n) return n;
    return par[n] = root(par[n]);
  }

  bool unite(size_t a, size_t b) {
    a = root(a);
    b = root(b);
    if (a == b) return false;
    group--;
    if (sz[a] < sz[b]) std::swap(a, b);
    sz[a] += sz[b];
    par[b] = a;
    return true;
  }

  size_t size() { return par.size(); }
  size_t groups() { return group; }
  size_t group_size(size_t n) { return sz[root(n)]; }

  bool same(size_t a, size_t b) { return root(a) == root(b); }
};
#line 85 "main_a.cpp"

int main() {
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

  i64 n;
  std::cin>>n;

  struct City{
    i64 x,y,itr;
  };

  std::vector<City> city(n);
  rep(i,0,n){
    std::cin>>city[i].x>>city[i].y;
    city[i].x--;
    city[i].y--;
    city[i].itr=i;
  }

  std::sort(all(city),[](const City& a,const City & b){return a.x<b.x;});

  using P=std::pair<i64,i64>;
  std::set<P> left;

  UnionFind uni(n);

  rep(i,0,n){
    bool unite=false;
    for(const auto& e:left){
      if(e.first >= city[i].y)break;
      uni.unite(e.second,city[i].itr);
      unite=true;
    }
    if(!unite)left.emplace(city[i].y,city[i].itr);
  }

  rep(i,0,n)std::cout<<uni.group_size(i)<<"\n";
  
  return 0;
}


Measured memory_bytes: 16032