#include <bits/stdc++.h>

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

// Verified: AOJ-DSL1A, AGC002D
class UFSet {
private:
  vector<int> ranks;
  vector<int> prevs;
  vector<int> sizes;

public:
  UFSet(int n) : ranks(n), prevs(n), sizes(n) {
    for (int i = 0; i < n; i++)
      prevs[i] = i;
    for (int i = 0; i < n; i++)
      sizes[i] = 1;
  }

  // Returns an ID of a set which x belongs to.
  int Find(int x) {
    if (x != prevs[x])
      prevs[x] = Find(prevs[x]);
    return prevs[x];
  }

  // Merges a set which x blongs to and a set which y belongs to.
  void Union(int x, int y) {
    int x_root = Find(x);
    int y_root = Find(y);
    if (ranks[x_root] > ranks[y_root]) {
      prevs[y_root] = prevs[x_root];
      sizes[x_root] += sizes[y_root];
    } else if (ranks[x_root] < ranks[y_root]) {
      prevs[x_root] = prevs[y_root];
      sizes[y_root] += sizes[x_root];
    } else if (prevs[x_root] != prevs[y_root]) {
      prevs[y_root] = prevs[x_root];
      ranks[x_root]++;
      sizes[x_root] += sizes[y_root];
    }
  }

  // Returns a size of a set which x belongs to.
  int Size(int x) { return sizes[Find(x)]; }
};

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

  int n;
  cin >> n;
  vector<tuple<int, int>> ps(n);
  vector<int> original_xs(n);
  for (int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    ps[i] = {x, y};
    original_xs[i] = x;
  }
  sort(ps.begin(), ps.end(),
       [](const auto &p1, const auto &p2) { return get<1>(p1) > get<1>(p2); });

  UFSet uf_set(n);
  set<int> s;

  for (const auto [x, y] : ps) {
    if (s.empty()) {
      s.insert(x);
    } else if (*s.rbegin() < x) {
      s.insert(x);
    } else {
      vector<int> remove_vector;
      for (auto it = s.rbegin(); it != s.rend(); it++) {
        if (*it > x) {
          if (it != s.rbegin())
            remove_vector.push_back(*it);
        }
      }
      for (int rx : remove_vector) {
        // cout << rx << " " << *s.rbegin() << endl;
        uf_set.Union(rx, *s.rbegin());
        s.erase(rx);
      }
      uf_set.Union(x, *s.rbegin());
    }

    // DUMP
    // for (int sx : s) {
    //   cout << sx << " ";
    // }
    // cout << endl;
  }

  for (int i = 0; i < n; i++) {
    cout << uf_set.Size(original_xs[i]) << "\\n";
  }
}

#include <bits/stdc++.h>

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

// Verified: AOJ-DSL1A, AGC002D
class UFSet {
private:
  vector<int> ranks;
  vector<int> prevs;
  vector<int> sizes;

public:
  UFSet(int n) : ranks(n), prevs(n), sizes(n) {
    for (int i = 0; i < n; i++)
      prevs[i] = i;
    for (int i = 0; i < n; i++)
      sizes[i] = 1;
  }

  // Returns an ID of a set which x belongs to.
  int Find(int x) {
    if (x != prevs[x])
      prevs[x] = Find(prevs[x]);
    return prevs[x];
  }

  // Merges a set which x blongs to and a set which y belongs to.
  void Union(int x, int y) {
    int x_root = Find(x);
    int y_root = Find(y);
    if (ranks[x_root] > ranks[y_root]) {
      prevs[y_root] = prevs[x_root];
      sizes[x_root] += sizes[y_root];
    } else if (ranks[x_root] < ranks[y_root]) {
      prevs[x_root] = prevs[y_root];
      sizes[y_root] += sizes[x_root];
    } else if (prevs[x_root] != prevs[y_root]) {
      prevs[y_root] = prevs[x_root];
      ranks[x_root]++;
      sizes[x_root] += sizes[y_root];
    }
  }

  // Returns a size of a set which x belongs to.
  int Size(int x) { return sizes[Find(x)]; }
};

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

  int n;
  cin >> n;
  vector<tuple<int, int>> ps(n);
  vector<int> original_xs(n);
  for (int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    ps[i] = {x, y};
    original_xs[i] = x;
  }
  sort(ps.begin(), ps.end(),
       [](const auto &p1, const auto &p2) { return get<1>(p1) > get<1>(p2); });

  UFSet uf_set(n);
  set<int> s;

  for (const auto [x, y] : ps) {
    if (s.empty()) {
      s.insert(x);
    } else if (*s.rbegin() < x) {
      s.insert(x);
    } else {
      vector<int> remove_vector;
      for (auto it = s.rbegin(); it != s.rend(); it++) {
        if (*it > x) {
          if (it != s.rbegin())
            remove_vector.push_back(*it);
        } else {
          break;
        }
      }
      for (int rx : remove_vector) {
        // cout << rx << " " << *s.rbegin() << endl;
        uf_set.Union(rx, *s.rbegin());
        s.erase(rx);
      }
      uf_set.Union(x, *s.rbegin());
    }

    // DUMP
    // for (int sx : s) {
    //   cout << sx << " ";
    // }
    // cout << endl;
  }

  for (int i = 0; i < n; i++) {
    cout << uf_set.Size(original_xs[i]) << "\\n";
  }
}


#include <bits/stdc++.h>

#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

class union_find {
  int n;
  vector<int> p;

public:
  union_find(int n) : n(n), p(n, -1) {}
  int find(int u) { return p[u] < 0 ? u : p[u] = find(p[u]); }
  void unite(int u, int v) {
    u = find(u);
    v = find(v);
    if (u != v) {
      if (p[v] < p[u])
        swap(u, v);
      p[u] += p[v];
      p[v] = u;
      n--;
    }
  }
  bool is_same(int u, int v) { return find(u) == find(v); }
  int size() const { return n; }
  int size(int u) { return -p[find(u)]; }
};

int main() {
  int n;
  scanf("%d", &n);
  vector<int> x(n), y(n);
  rep(i, n) scanf("%d%d", &x[i], &y[i]), x[i]--, y[i]--;

  vector<int> p(n);
  iota(p.begin(), p.end(), 0);
  sort(p.begin(), p.end(), [&](int i, int j) { return x[i] < x[j]; });

  vector<pair<int, int>> H;
  union_find UL(n), UR(n);
  map<int, int> L, R;
  for (int i : p)
    if (UL.size(i) == 1) {
      for (auto it = L.lower_bound(y[i]); it != L.begin();) {
        --it;
        UL.unite(i, it->second);
        H.emplace_back(i, it->second);
      }
      L[y[i]] = i;
    }
  reverse(p.begin(), p.end());
  for (int i : p)
    if (UR.size(i) == 1) {
      for (auto it = R.lower_bound(y[i]); it != R.end(); ++it) {
        UR.unite(i, it->second);
        H.emplace_back(i, it->second);
      }
      R[y[i]] = i;
    }

  union_find U(n);
  for (auto e : H)
    U.unite(e.first, e.second);
  rep(i, n) printf("%d\\n", U.size(i));

  return 0;
}

#include <bits/stdc++.h>

#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

class union_find {
  int n;
  vector<int> p;

public:
  union_find(int n) : n(n), p(n, -1) {}
  int find(int u) { return p[u] < 0 ? u : p[u] = find(p[u]); }
  void unite(int u, int v) {
    u = find(u);
    v = find(v);
    if (u != v) {
      if (p[v] < p[u])
        swap(u, v);
      p[u] += p[v];
      p[v] = u;
      n--;
    }
  }
  bool is_same(int u, int v) { return find(u) == find(v); }
  int size() const { return n; }
  int size(int u) { return -p[find(u)]; }
};

template <class T> struct interval {
  T l, r;
  interval() {}
  interval(const T &l, const T &r) : l(l), r(r) {}
  bool operator<(const interval &I) const {
    return make_tuple(l, r) < make_tuple(I.l, I.r);
  }
};

template <class T> vector<interval<T>> interval_union(vector<interval<T>> I) {
  sort(I.begin(), I.end(),
       [](const interval<T> &a, const interval<T> &b) { return a.l < b.l; });

  int n = I.size();
  if (n == 0)
    return {};

  vector<interval<T>> res;
  T l = I[0].l, r = I[0].r;
  for (int i = 1; i <= n; i++) {
    if (i == n || r < I[i].l) {
      res.emplace_back(l, r);
      if (i < n) {
        l = I[i].l;
        r = I[i].r;
      }
    } else if (r < I[i].r) {
      r = I[i].r;
    }
  }
  return res;
}

int main() {
  int n;
  scanf("%d", &n);
  vector<int> x(n), y(n);
  rep(i, n) scanf("%d%d", &x[i], &y[i]), x[i]--, y[i]--;

  vector<int> p(n);
  iota(p.begin(), p.end(), 0);
  sort(p.begin(), p.end(), [&](int i, int j) { return x[i] < x[j]; });

  union_find U(n);
  vector<interval<int>> H;
  vector<int> I, Y;
  int y_pre = -1;
  for (int i = n - 1; i >= 0; i--) {
    int idx = p[i];
    // printf("(%d, %d)\\n",x[idx]+1,y[idx]+1);

    int l = upper_bound(Y.begin(), Y.end(), y[idx]) - Y.begin();
    if (l < Y.size()) {
      // printf("  l = %d, unite(%d, %d), add [%d,
      // %ld)\\n",l,idx,I[l],l,Y.size());
      U.unite(idx, I[l]);
      H.emplace_back(l, Y.size() - 1);
    }

    if (y[idx] > y_pre) {
      I.emplace_back(idx);
      Y.emplace_back(y[idx]);
      y_pre = y[idx];
    }
    // printf("  |Y| = %ld\\n",Y.size());
  }

  for (auto J : interval_union(H)) {
    for (int i = J.l; i < J.r; i++)
      U.unite(I[i], I[i + 1]);
    //		for(int i=J.l;i<J.r;i++) printf("unite %d %d\\n",I[i],I[i+1]);
  }
  rep(i, n) printf("%d\\n", U.size(i));

  return 0;
}


#include <bits/stdc++.h>
#define LL long long
#define DB long double
using namespace std;
// #define P 998244353
// inline int ad(int x,int y){return (x+y>=P)?(x+y-P):(x+y);}
// inline int mt(int x,int y){return 1ll*x*y%P;}
// inline void mo(int &x){x=(x>=P)?(x-P):x; x=(x<0)?(x+P):x;}
template <typename T> inline void ckmx(T &x, T y) { x = max(x, y); }
template <typename T> inline void ckmi(T &x, T y) { x = min(x, y); }
template <typename T> void read(T &x) {
  x = 0;
  int f = 1;
  char c = getchar();
  for (; !isdigit(c); c = getchar())
    if (c == '-')
      f = -1;
  for (; isdigit(c); c = getchar())
    x = x * 10 + c - 48;
  x *= f;
}
int n;
int x[200010], y[200010];
int id[200010];
int fa[200010], cnt[200010];
int gtf(int x) {
  if (fa[x] == x)
    return x;
  else
    return fa[x] = gtf(fa[x]);
}
int mg(int x, int y) {
  x = gtf(x);
  y = gtf(y);
  fa[x] = y;
  cnt[y] += cnt[x];
}
int q[200010], top, mi;
int main() {
  read(n);
  for (int i = 1; i <= n; ++i)
    read(x[i]), read(y[i]), id[x[i]] = i, fa[i] = i, cnt[i]++;
  mi = id[1];
  for (int i = 2; i <= n; ++i) {
    int nw = id[i];
    if (y[nw] < y[mi])
      q[++top] = mi, mi = nw;
    else {
      while (top && y[nw] > y[q[top]])
        mg(nw, q[top]), --top;
      mg(nw, mi);
    }
  }
  for (int i = 1; i <= n; ++i)
    printf("%d\\n", cnt[gtf(i)]);
  return 0;
}

#include <iostream>
/*#define LL long long
#define DB long double*/
using namespace std;
// #define P 998244353
// inline int ad(int x,int y){return (x+y>=P)?(x+y-P):(x+y);}
// inline int mt(int x,int y){return 1ll*x*y%P;}
// inline void mo(int &x){x=(x>=P)?(x-P):x; x=(x<0)?(x+P):x;}
// template<typename T>inline void ckmx(T &x,T y){x=max(x,y);}
// template<typename T>inline void ckmi(T &x,T y){x=min(x,y);}
template <typename T> void rd(T &x) {
  x = 0;
  int f = 1;
  char c = getchar();
  for (; !isdigit(c); c = getchar())
    if (c == '-')
      f = -1;
  for (; isdigit(c); c = getchar())
    x = x * 10 + c - 48;
  x *= f;
}
int n;
int x[200010], y[200010];
int id[200010];
int fa[200010], cnt[200010];
int gtf(int x) {
  if (fa[x] == x)
    return x;
  else
    return fa[x] = gtf(fa[x]);
}
void mg(int x, int y) {
  x = gtf(x);
  y = gtf(y);
  fa[x] = y;
  cnt[y] += cnt[x];
}
int q[200010], tp = 0, mi;
int main() {
  rd(n);
  for (int i = 1; i <= n; ++i)
    rd(x[i]), rd(y[i]), id[x[i]] = i, fa[i] = i, cnt[i]++;
  mi = id[1];
  for (int i = 2; i <= n; ++i) {
    int nw = id[i];
    if (y[nw] < y[mi])
      q[++tp] = mi, mi = nw;
    else {
      while (tp > 0 && y[nw] > y[q[tp]])
        mg(nw, q[tp]), --tp;
      mg(nw, mi);
    }
  }
  for (int i = 1; i <= n; ++i)
    printf("%d\\n", cnt[gtf(i)]);
  return 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define pa pair<int, int>
#define pal pair<long long, long long>
#define pali pair<long long, int>
#define pad pair<double, double>
#define pb push_back
#define mp make_pair
#define COUT(v)                                                                \\
  for (int64_t i = 0; i < (v).size(); ++i) {                                   \\
    cout << v.at(i) << endl;                                                   \\
  }
#define REP(i, n) for (int64_t i = 0; i < n; ++i)
#define FOR(i, r, n) for (int64_t i = (r); i < n; ++i)
#define VIN(v)                                                                 \\
  for (int64_t i = 0; i < (v).size(); ++i) {                                   \\
    cin >> (v).at(i);                                                          \\
  }

typedef vector<bool> bvec;
typedef vector<int> ivec;
typedef vector<long long> lvec;
typedef vector<double> dvec;
typedef vector<pa> pavec;
typedef vector<pali> palivec;
typedef vector<pal> palvec;

typedef vector<vector<bool>> bmat;
typedef vector<vector<int>> imat;
typedef vector<vector<long long>> lmat;

typedef vector<string> svec;
typedef vector<vector<string>> smat;
const ll infll = (1LL << 60) - 1;
const int inf = (1 << 30) - 1;
const ll MOD = 1000000007;

ll gcd(ll x, ll y) {
  ll r = x % y;
  if (r == 0)
    return y;
  else
    return gcd(y, r);
}

ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

lvec mfactor(ll n) {
  bvec ip(n, true);
  lvec mf(n, -1);
  ip[0] = false;
  ip[1] = false;
  mf[0] = 0;
  mf[1] = 1;
  REP(i, n) {
    if (ip[i]) {
      mf[i] = i;
      for (ll j = i * i; j < n; j += i) {
        ip[j] = false;
        if (mf[j] == -1)
          mf[j] = i;
      }
    }
  }
  return mf;
}

palivec get_prime(ll n, const lvec &mf) {
  palivec plist;
  while (n != 1) {
    int cnt = 0;
    ll m = mf[n];
    while (mf[n] == m) {
      cnt++;
      n /= m;
    }
    plist.pb(pali(m, cnt));
  }
  return plist;
}

void COMinit(int m, lvec &fac, lvec &finv) {
  lvec inv(m);
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < m; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

ll pow_mod(ll a, ll n) {
  ll x = 1;
  while (n > 0) {
    if (n & 1) {
      x = x * a % MOD;
    }
    a = a * a % MOD;
    n >>= 1;
  }
  return x;
}

ll pow_mod2(ll a, ll n) {
  ll x = 1;
  while (n > 0) {
    if (n & 1) {
      x = x * a;
    }
    a = a * a;
    n >>= 1;
  }
  return x;
}

ll COM(int n, int k, const lvec &fac, const lvec &finv) {
  if (n < k)
    return 0;
  if (n < 0 || k < 0)
    return 0;
  return (fac[n] * (finv[k] * finv[n - k] % MOD)) % MOD;
}

ll modinv(ll a, ll m) {
  ll b = m, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  u %= m;
  if (u < 0)
    u += m;
  return u;
}

// union by size + path having
class UnionFind {
public:
  vector<ll> par;
  vector<ll> siz;

  // Constructor
  UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
    for (ll i = 0; i < sz_; ++i)
      par[i] = i;
  }
  void init(ll sz_) {
    par.resize(sz_);
    siz.assign(sz_, 1LL);
    for (ll i = 0; i < sz_; ++i)
      par[i] = i;
  }

  // Member Function
  // Find
  ll root(ll x) {
    while (par[x] != x) {
      x = par[x] = par[par[x]];
    }
    return x;
  }

  // Union(Unite, Merge)
  bool merge(ll x, ll y) {
    x = root(x);
    y = root(y);
    if (x == y)
      return false;
    if (siz[x] < siz[y])
      swap(x, y);
    siz[x] += siz[y];
    par[y] = x;
    return true;
  }

  bool issame(ll x, ll y) { return root(x) == root(y); }

  ll size(ll x) { return siz[root(x)]; }
};

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;
  cin >> n;
  lvec x(n), y(n), ind(n);
  set<ll> s;
  for (int i = 0; i < n; i++) {
    cin >> x[i] >> y[i];
    ind[i] = i;
    s.insert(i);
  }
  sort(ind.begin(), ind.end(), [&x](ll a, ll b) { return x[a] < x[b]; });
  UnionFind u(n);
  bvec m(n, false);
  for (int i = 0; i < n - 1; i++) {
    ll idx = ind[i];
    if (m[idx]) {
      continue;
    }
    for (int j = i + 1; j < n; j++) {
      ll v = ind[j];
      if (y[idx] < y[v]) {
        u.merge(idx, v);
        m[v] = true;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    cout << u.size(i) << endl;
  }
}

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define pa pair<int, int>
#define pal pair<long long, long long>
#define pali pair<long long, int>
#define pad pair<double, double>
#define pb push_back
#define mp make_pair
#define COUT(v)                                                                \\
  for (int64_t i = 0; i < (v).size(); ++i) {                                   \\
    cout << v.at(i) << endl;                                                   \\
  }
#define REP(i, n) for (int64_t i = 0; i < n; ++i)
#define FOR(i, r, n) for (int64_t i = (r); i < n; ++i)
#define VIN(v)                                                                 \\
  for (int64_t i = 0; i < (v).size(); ++i) {                                   \\
    cin >> (v).at(i);                                                          \\
  }

typedef vector<bool> bvec;
typedef vector<int> ivec;
typedef vector<long long> lvec;
typedef vector<double> dvec;
typedef vector<pa> pavec;
typedef vector<pali> palivec;
typedef vector<pal> palvec;

typedef vector<vector<bool>> bmat;
typedef vector<vector<int>> imat;
typedef vector<vector<long long>> lmat;

typedef vector<string> svec;
typedef vector<vector<string>> smat;
const ll infll = (1LL << 60) - 1;
const int inf = (1 << 30) - 1;
const ll MOD = 1000000007;

ll gcd(ll x, ll y) {
  ll r = x % y;
  if (r == 0)
    return y;
  else
    return gcd(y, r);
}

ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

lvec mfactor(ll n) {
  bvec ip(n, true);
  lvec mf(n, -1);
  ip[0] = false;
  ip[1] = false;
  mf[0] = 0;
  mf[1] = 1;
  REP(i, n) {
    if (ip[i]) {
      mf[i] = i;
      for (ll j = i * i; j < n; j += i) {
        ip[j] = false;
        if (mf[j] == -1)
          mf[j] = i;
      }
    }
  }
  return mf;
}

palivec get_prime(ll n, const lvec &mf) {
  palivec plist;
  while (n != 1) {
    int cnt = 0;
    ll m = mf[n];
    while (mf[n] == m) {
      cnt++;
      n /= m;
    }
    plist.pb(pali(m, cnt));
  }
  return plist;
}

void COMinit(int m, lvec &fac, lvec &finv) {
  lvec inv(m);
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < m; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

ll pow_mod(ll a, ll n) {
  ll x = 1;
  while (n > 0) {
    if (n & 1) {
      x = x * a % MOD;
    }
    a = a * a % MOD;
    n >>= 1;
  }
  return x;
}

ll pow_mod2(ll a, ll n) {
  ll x = 1;
  while (n > 0) {
    if (n & 1) {
      x = x * a;
    }
    a = a * a;
    n >>= 1;
  }
  return x;
}

ll COM(int n, int k, const lvec &fac, const lvec &finv) {
  if (n < k)
    return 0;
  if (n < 0 || k < 0)
    return 0;
  return (fac[n] * (finv[k] * finv[n - k] % MOD)) % MOD;
}

ll modinv(ll a, ll m) {
  ll b = m, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  u %= m;
  if (u < 0)
    u += m;
  return u;
}

// union by size + path having
class UnionFind {
public:
  vector<ll> par;
  vector<ll> siz;

  // Constructor
  UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
    for (ll i = 0; i < sz_; ++i)
      par[i] = i;
  }
  void init(ll sz_) {
    par.resize(sz_);
    siz.assign(sz_, 1LL);
    for (ll i = 0; i < sz_; ++i)
      par[i] = i;
  }

  // Member Function
  // Find
  ll root(ll x) {
    while (par[x] != x) {
      x = par[x] = par[par[x]];
    }
    return x;
  }

  // Union(Unite, Merge)
  bool merge(ll x, ll y) {
    x = root(x);
    y = root(y);
    if (x == y)
      return false;
    if (siz[x] < siz[y])
      swap(x, y);
    siz[x] += siz[y];
    par[y] = x;
    return true;
  }

  bool issame(ll x, ll y) { return root(x) == root(y); }

  ll size(ll x) { return siz[root(x)]; }
};

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;
  cin >> n;
  lvec x(n), y(n), indx(n);
  map<ll, ll, greater<ll>> m;
  for (int i = 0; i < n; i++) {
    cin >> x[i] >> y[i];
    indx[i] = i;
    m[y[i]] = x[i];
  }
  sort(indx.begin(), indx.end(), [&x](ll a, ll b) { return x[a] < x[b]; });

  lvec xx(n + 1);
  for (int i = 0; i < n; i++) {
    xx[x[indx[i]]] = indx[i];
  }
  UnionFind u(n);
  bvec li(n, false);
  for (int i = 0; i < n - 1; i++) {
    ll idx = indx[i];
    m.erase(y[idx]);
    if (li[idx]) {
      continue;
    }
    for (auto p : m) {
      ll k = p.first, v = p.second;
      if (y[idx] < k) {
        u.merge(idx, xx[v]);
        li[xx[v]] = true;
      } else {
        break;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    cout << u.size(i) << endl;
  }
}


#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define pa pair<int, int>
#define pal pair<long long, long long>
#define pali pair<long long, int>
#define pad pair<double, double>
#define pb push_back
#define mp make_pair
#define COUT(v)                                                                \\
  for (int64_t i = 0; i < (v).size(); ++i) {                                   \\
    cout << v.at(i) << endl;                                                   \\
  }
#define REP(i, n) for (int64_t i = 0; i < n; ++i)
#define FOR(i, r, n) for (int64_t i = (r); i < n; ++i)
#define VIN(v)                                                                 \\
  for (int64_t i = 0; i < (v).size(); ++i) {                                   \\
    cin >> (v).at(i);                                                          \\
  }

typedef vector<bool> bvec;
typedef vector<int> ivec;
typedef vector<long long> lvec;
typedef vector<double> dvec;
typedef vector<pa> pavec;
typedef vector<pali> palivec;
typedef vector<pal> palvec;

typedef vector<vector<bool>> bmat;
typedef vector<vector<int>> imat;
typedef vector<vector<long long>> lmat;

typedef vector<string> svec;
typedef vector<vector<string>> smat;
const ll infll = (1LL << 60) - 1;
const int inf = (1 << 30) - 1;
const ll MOD = 1000000007;

ll gcd(ll x, ll y) {
  ll r = x % y;
  if (r == 0)
    return y;
  else
    return gcd(y, r);
}

ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

lvec mfactor(ll n) {
  bvec ip(n, true);
  lvec mf(n, -1);
  ip[0] = false;
  ip[1] = false;
  mf[0] = 0;
  mf[1] = 1;
  REP(i, n) {
    if (ip[i]) {
      mf[i] = i;
      for (ll j = i * i; j < n; j += i) {
        ip[j] = false;
        if (mf[j] == -1)
          mf[j] = i;
      }
    }
  }
  return mf;
}

palivec get_prime(ll n, const lvec &mf) {
  palivec plist;
  while (n != 1) {
    int cnt = 0;
    ll m = mf[n];
    while (mf[n] == m) {
      cnt++;
      n /= m;
    }
    plist.pb(pali(m, cnt));
  }
  return plist;
}

void COMinit(int m, lvec &fac, lvec &finv) {
  lvec inv(m);
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < m; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

ll pow_mod(ll a, ll n) {
  ll x = 1;
  while (n > 0) {
    if (n & 1) {
      x = x * a % MOD;
    }
    a = a * a % MOD;
    n >>= 1;
  }
  return x;
}

ll pow_mod2(ll a, ll n) {
  ll x = 1;
  while (n > 0) {
    if (n & 1) {
      x = x * a;
    }
    a = a * a;
    n >>= 1;
  }
  return x;
}

ll COM(int n, int k, const lvec &fac, const lvec &finv) {
  if (n < k)
    return 0;
  if (n < 0 || k < 0)
    return 0;
  return (fac[n] * (finv[k] * finv[n - k] % MOD)) % MOD;
}

ll modinv(ll a, ll m) {
  ll b = m, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  u %= m;
  if (u < 0)
    u += m;
  return u;
}

// union by size + path having
class UnionFind {
public:
  vector<ll> par;
  vector<ll> siz;

  // Constructor
  UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
    for (ll i = 0; i < sz_; ++i)
      par[i] = i;
  }
  void init(ll sz_) {
    par.resize(sz_);
    siz.assign(sz_, 1LL);
    for (ll i = 0; i < sz_; ++i)
      par[i] = i;
  }

  // Member Function
  // Find
  ll root(ll x) {
    while (par[x] != x) {
      x = par[x] = par[par[x]];
    }
    return x;
  }

  // Union(Unite, Merge)
  bool merge(ll x, ll y) {
    x = root(x);
    y = root(y);
    if (x == y)
      return false;
    if (siz[x] < siz[y])
      swap(x, y);
    siz[x] += siz[y];
    par[y] = x;
    return true;
  }

  bool issame(ll x, ll y) { return root(x) == root(y); }

  ll size(ll x) { return siz[root(x)]; }
};

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;
  cin >> n;
  lvec y(n), ind(n);
  map<ll, ll, greater<ll>> s;
  for (int i = 0; i < n; i++) {
    ll xx, yy;
    cin >> xx >> yy;
    --xx, --yy;
    y[xx] = yy;
    ind[xx] = i;
    s[yy] = xx;
  }
  UnionFind u(n);
  for (int i = 0; i < n - 1; i++) {

    s.erase(y[i]);
    for (auto p : s) {
      ll yy = p.first, xx = p.second;
      if (yy < y[i]) {
        break;
      }
      u.merge(ind[xx], ind[i]);
    }
  }

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

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define pa pair<int, int>
#define pal pair<long long, long long>
#define pali pair<long long, int>
#define pad pair<double, double>
#define pb push_back
#define mp make_pair
#define COUT(v)                                                                \\
  for (int64_t i = 0; i < (v).size(); ++i) {                                   \\
    cout << v.at(i) << endl;                                                   \\
  }
#define REP(i, n) for (int64_t i = 0; i < n; ++i)
#define FOR(i, r, n) for (int64_t i = (r); i < n; ++i)
#define VIN(v)                                                                 \\
  for (int64_t i = 0; i < (v).size(); ++i) {                                   \\
    cin >> (v).at(i);                                                          \\
  }

typedef vector<bool> bvec;
typedef vector<int> ivec;
typedef vector<long long> lvec;
typedef vector<double> dvec;
typedef vector<pa> pavec;
typedef vector<pali> palivec;
typedef vector<pal> palvec;

typedef vector<vector<bool>> bmat;
typedef vector<vector<int>> imat;
typedef vector<vector<long long>> lmat;

typedef vector<string> svec;
typedef vector<vector<string>> smat;
const ll infll = (1LL << 60) - 1;
const int inf = (1 << 30) - 1;
const ll MOD = 1000000007;

ll gcd(ll x, ll y) {
  ll r = x % y;
  if (r == 0)
    return y;
  else
    return gcd(y, r);
}

ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

lvec mfactor(ll n) {
  bvec ip(n, true);
  lvec mf(n, -1);
  ip[0] = false;
  ip[1] = false;
  mf[0] = 0;
  mf[1] = 1;
  REP(i, n) {
    if (ip[i]) {
      mf[i] = i;
      for (ll j = i * i; j < n; j += i) {
        ip[j] = false;
        if (mf[j] == -1)
          mf[j] = i;
      }
    }
  }
  return mf;
}

palivec get_prime(ll n, const lvec &mf) {
  palivec plist;
  while (n != 1) {
    int cnt = 0;
    ll m = mf[n];
    while (mf[n] == m) {
      cnt++;
      n /= m;
    }
    plist.pb(pali(m, cnt));
  }
  return plist;
}

void COMinit(int m, lvec &fac, lvec &finv) {
  lvec inv(m);
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < m; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

ll pow_mod(ll a, ll n) {
  ll x = 1;
  while (n > 0) {
    if (n & 1) {
      x = x * a % MOD;
    }
    a = a * a % MOD;
    n >>= 1;
  }
  return x;
}

ll pow_mod2(ll a, ll n) {
  ll x = 1;
  while (n > 0) {
    if (n & 1) {
      x = x * a;
    }
    a = a * a;
    n >>= 1;
  }
  return x;
}

ll COM(int n, int k, const lvec &fac, const lvec &finv) {
  if (n < k)
    return 0;
  if (n < 0 || k < 0)
    return 0;
  return (fac[n] * (finv[k] * finv[n - k] % MOD)) % MOD;
}

ll modinv(ll a, ll m) {
  ll b = m, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  u %= m;
  if (u < 0)
    u += m;
  return u;
}

// union by size + path having
class UnionFind {
public:
  vector<ll> par;
  vector<ll> siz;

  // Constructor
  UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
    for (ll i = 0; i < sz_; ++i)
      par[i] = i;
  }
  void init(ll sz_) {
    par.resize(sz_);
    siz.assign(sz_, 1LL);
    for (ll i = 0; i < sz_; ++i)
      par[i] = i;
  }

  // Member Function
  // Find
  ll root(ll x) {
    while (par[x] != x) {
      x = par[x] = par[par[x]];
    }
    return x;
  }

  // Union(Unite, Merge)
  bool merge(ll x, ll y) {
    x = root(x);
    y = root(y);
    if (x == y)
      return false;
    if (siz[x] < siz[y])
      swap(x, y);
    siz[x] += siz[y];
    par[y] = x;
    return true;
  }

  bool issame(ll x, ll y) { return root(x) == root(y); }

  ll size(ll x) { return siz[root(x)]; }
};

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;
  cin >> n;
  lvec y(n), ind(n);
  map<ll, ll, greater<ll>> s;
  for (int i = 0; i < n; i++) {
    ll xx, yy;
    cin >> xx >> yy;
    --xx, --yy;
    y[xx] = yy;
    ind[xx] = i;
    s[yy] = xx;
  }
  UnionFind u(n);
  bvec m(n, false);
  for (int i = 0; i < n - 1; i++) {
    s.erase(y[i]);
    if (m[i]) {
      continue;
    }
    for (auto p : s) {
      ll yy = p.first, xx = p.second;
      if (yy < y[i]) {
        break;
      }
      u.merge(ind[xx], ind[i]);
      m[xx] = true;
    }
  }

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


/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;
typedef long long ll;
typedef long double ld;

int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int> &f, const pair<int, int> &s) {
  return f.second > s.second;
}

ll gcd(ll a, ll b) {
  if (b == 0)
    return a;
  return gcd(b, a % b);
}

ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

ll conbinationMemo[100][100];

void cmemoInit() {
  rep(i, 100) {
    rep(j, 100) { conbinationMemo[i][j] = -1; }
  }
}

ll nCr(ll n, ll r) {
  if (conbinationMemo[n][r] != -1)
    return conbinationMemo[n][r];
  if (r == 0 || r == n) {
    return 1;
  } else if (r == 1) {
    return n;
  }
  return conbinationMemo[n][r] = (nCr(n - 1, r) + nCr(n - 1, r - 1));
}

ll nPr(ll n, ll r) {
  r = n - r;
  ll ret = 1;
  for (ll i = n; i >= r + 1; i--)
    ret *= i;
  return ret;
}
//-----------------------ここから-----------
struct UnionFind {
  vector<ll> parent;
  vector<ll> s;

  UnionFind(ll n) {
    parent.resize(n);
    s.resize(n, 1);
    for (int i = 0; i < n; i++)
      parent[i] = i;
  }

  ll root(ll node) {
    if (parent[node] == node) {
      return node;
    } else {
      return parent[node] = root(parent[node]);
    }
  }

  void unite(ll x, ll y) {
    ll rootx = root(x);
    ll rooty = root(y);
    if (rootx == rooty)
      return;
    if (s[rootx] < s[rooty])
      swap(rootx, rooty);
    s[rootx] += s[rooty];
    parent[rooty] = rootx;
  }

  bool isSame(ll x, ll y) { return root(x) == root(y); }

  ll size(ll x) { return s[root(x)]; }
};
int main(void) {
  ll n;
  cin >> n;
  vector<pair<pair<ll, ll>, ll>> vecx, vecy;
  rep(i, n) {
    ll x, y;
    cin >> x >> y;
    vecx.push_back({{x, y}, i});
  }

  sort(all(vecx), greater<pair<pair<ll, ll>, ll>>());

  UnionFind uf(n);
  vector<pair<ll, ll>> mi(200200, {-INF, -INF});
  set<ll> rt;
  for (ll i = 0; i < n; i++) {
    for (auto &j : rt) {
      if (mi[j].first > vecx[i].first.second) {
        uf.unite(vecx[i].second, mi[j].second);
      }
    }
    ll root = uf.root(vecx[i].second);
    if (mi[root].first < vecx[i].first.second) {
      mi[root] = {vecx[i].first.second, vecx[i].second};
    }
    rt.insert(root);
  }

  rep(i, n) { cout << uf.size(i) << endl; }
}

/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;
typedef long long ll;
typedef long double ld;

int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int> &f, const pair<int, int> &s) {
  return f.second > s.second;
}

ll gcd(ll a, ll b) {
  if (b == 0)
    return a;
  return gcd(b, a % b);
}

ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

ll conbinationMemo[100][100];

void cmemoInit() {
  rep(i, 100) {
    rep(j, 100) { conbinationMemo[i][j] = -1; }
  }
}

ll nCr(ll n, ll r) {
  if (conbinationMemo[n][r] != -1)
    return conbinationMemo[n][r];
  if (r == 0 || r == n) {
    return 1;
  } else if (r == 1) {
    return n;
  }
  return conbinationMemo[n][r] = (nCr(n - 1, r) + nCr(n - 1, r - 1));
}

ll nPr(ll n, ll r) {
  r = n - r;
  ll ret = 1;
  for (ll i = n; i >= r + 1; i--)
    ret *= i;
  return ret;
}
//-----------------------ここから-----------
struct UnionFind {
  vector<ll> parent;
  vector<ll> s;

  UnionFind(ll n) {
    parent.resize(n);
    s.resize(n, 1);
    for (int i = 0; i < n; i++)
      parent[i] = i;
  }

  ll root(ll node) {
    if (parent[node] == node) {
      return node;
    } else {
      return parent[node] = root(parent[node]);
    }
  }

  void unite(ll x, ll y) {
    ll rootx = root(x);
    ll rooty = root(y);
    if (rootx == rooty)
      return;
    if (s[rootx] < s[rooty])
      swap(rootx, rooty);
    s[rootx] += s[rooty];
    parent[rooty] = rootx;
  }

  bool isSame(ll x, ll y) { return root(x) == root(y); }

  ll size(ll x) { return s[root(x)]; }
};
int main(void) {
  ll n;
  cin >> n;
  vector<pair<pair<ll, ll>, ll>> vecx, vecy;
  rep(i, n) {
    ll x, y;
    cin >> x >> y;
    vecx.push_back({{x, y}, i});
  }

  sort(all(vecx));

  UnionFind uf(n);
  vector<pair<ll, ll>> mi(200200, {INF, INF});
  set<pair<ll, ll>> rt;
  for (ll i = 0; i < n; i++) {
    for (auto &j : rt) {
      if (j.first < vecx[i].first.second) {
        uf.unite(vecx[i].second, j.second);
      } else {
        break;
      }
    }
    ll root = uf.root(vecx[i].second);
    if (mi[root].first > vecx[i].first.second) {
      rt.erase({mi[root].first, root});
      mi[root] = {vecx[i].first.second, vecx[i].second};
      rt.insert({mi[root].first, root});
    }
  }

  rep(i, n) { cout << uf.size(i) << endl; }
}


#include <algorithm>
#include <cstring>
#include <iostream>
#include <stack>
using namespace std;

const int maxn = 15;
int n, a[maxn], x[maxn], y[maxn], mx[maxn], mn[maxn], p[maxn];

bool cmp(int b, int c) { return x[b] < x[c]; }
int f(int b) {
  if (p[b] < 0)
    return b;
  return p[b] = f(p[b]);
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> x[i] >> y[i];
    a[i] = i;
  }
  sort(a + 1, a + n + 1, cmp);
  stack<int> stk;
  for (int i = 1; i <= n; i++) {
    mn[a[i]] = y[a[i]];
    mx[a[i]] = y[a[i]];
    p[a[i]] = -1;
    while (!stk.empty() && mx[a[i]] > mn[stk.top()]) {
      mn[a[i]] = min(mn[a[i]], mn[stk.top()]);
      mx[a[i]] = max(mx[a[i]], mx[stk.top()]);
      p[a[i]] += p[stk.top()];
      p[stk.top()] = a[i];
      stk.pop();
    }
    stk.push(a[i]);
  }
  for (int i = 1; i <= n; i++) {
    cout << -p[f(i)] << "\\n";
  }
}

#include <algorithm>
#include <cstring>
#include <iostream>
#include <stack>
using namespace std;

const int maxn = 200005;
int n, a[maxn], x[maxn], y[maxn], mx[maxn], mn[maxn], p[maxn];

bool cmp(int b, int c) { return x[b] < x[c]; }
int f(int b) {
  if (p[b] < 0)
    return b;
  return p[b] = f(p[b]);
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> x[i] >> y[i];
    a[i] = i;
  }
  sort(a + 1, a + n + 1, cmp);
  stack<int> stk;
  for (int i = 1; i <= n; i++) {
    mn[a[i]] = y[a[i]];
    mx[a[i]] = y[a[i]];
    p[a[i]] = -1;
    while (!stk.empty() && mx[a[i]] > mn[stk.top()]) {
      mn[a[i]] = min(mn[a[i]], mn[stk.top()]);
      mx[a[i]] = max(mx[a[i]], mx[stk.top()]);
      p[a[i]] += p[stk.top()];
      p[stk.top()] = a[i];
      stk.pop();
    }
    stk.push(a[i]);
  }
  for (int i = 1; i <= n; i++) {
    cout << -p[f(i)] << "\\n";
  }
}


#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define P pair<int, int>

typedef vector<int> vec;
typedef vector<vec> mat;

const ll mod = 1000000007;

int const MAX_N = 100000;
int par[MAX_N];   // 親
int depth[MAX_N]; // 木の深さ
int num[MAX_N];

// n要素で初期化
void init(int n) {
  for (int i = 0; i < n; i++) {
    par[i] = i;
    depth[i] = 0;
    num[i] = 1;
  }
}

// 木の根を求める
int find(int x) {
  if (par[x] == x) {
    return x;
  } else {
    return par[x] = find(par[x]);
  }
}

int count(int x) { return num[par[x]]; }

// xとyの属する集合を合併
void unite(int x, int y) {
  x = find(x);
  y = find(y);
  if (x == y)
    return;

  if (depth[x] < depth[y]) {
    par[x] = y;
    num[y] += num[x];
  } else {
    par[y] = x;
    num[x] += num[y];
    if (depth[x] == depth[y])
      depth[x]++;
  }
}

// xとyが同じ集合に属するか否か
bool same(int x, int y) { return find(x) == find(y); }

int main() {
  int n;
  cin >> n;
  pair<P, int> x[n];
  rep(i, n) {
    cin >> x[i].first.first >> x[i].first.second;
    x[i].second = i;
  }
  sort(x, x + n);
  init(n);
  rep(i, n) {
    int idx = x[i].second;
    if (count(idx) != 1)
      continue;
    for (int j = i + 1; j < n; j++) {
      if (x[i].first.second < x[j].first.second) {
        unite(idx, x[j].second);
      }
    }
    // cout << i << endl;
  }
  rep(i, n) { cout << count(i) << endl; }
}

#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define P pair<int, int>

typedef vector<int> vec;
typedef vector<vec> mat;

const ll mod = 1000000007;

int const MAX_N = 200010;
int par[MAX_N];   // 親
int depth[MAX_N]; // 木の深さ
int num[MAX_N];

// n要素で初期化
void init(int n) {
  for (int i = 0; i < n; i++) {
    par[i] = i;
    depth[i] = 0;
    num[i] = 1;
  }
}

// 木の根を求める
int find(int x) {
  if (par[x] == x) {
    return x;
  } else {
    return par[x] = find(par[x]);
  }
}

int count(int x) { return num[find(x)]; }

// xとyの属する集合を合併
void unite(int x, int y) {
  x = find(x);
  y = find(y);
  if (x == y)
    return;

  if (depth[x] < depth[y]) {
    par[x] = y;
    num[y] += num[x];
  } else {
    par[y] = x;
    num[x] += num[y];
    if (depth[x] == depth[y])
      depth[x]++;
  }
}

// xとyが同じ集合に属するか否か
bool same(int x, int y) { return find(x) == find(y); }

int main() {
  int n;
  cin >> n;
  set<P> sx1, sx2;
  set<P> sy1, sy2;
  P dec[n];
  rep(i, n) {
    int x, y;
    cin >> x >> y;
    dec[i].first = x;
    dec[i].second = y;
    sx1.insert(P(x, i));
    sy1.insert(P(y, i));
    sx2.insert(P(x, i));
    sy2.insert(P(y, i));
  }
  init(n);
  // rep(i, n){
  //     cout << x[i].first.first << " " << x[i].first.second << endl;
  // }
  while (sx1.size() > 0) {
    // for (auto it = sx1.begin(); it != sx1.end(); it++){
    //     cout << (*it).first << ":" << (*it).second << " ";
    // }cout << endl;
    // for (auto it = sy1.begin(); it != sy1.end(); it++){
    //     cout << (*it).first << ":" << (*it).second << " ";
    // }cout << endl;
    P x = *sx1.begin();
    int idx = x.second;
    int y = dec[idx].second;
    sx1.erase(sx1.begin());
    auto itr = sy1.end();
    itr--;
    while ((*itr).second != idx) {
      // cout << (*itr).first << endl;
      unite((*itr).second, idx);
      sy1.erase(itr);
      int idx_ = (*itr).second;
      sx1.erase(P(dec[idx_].first, idx_));
      // cout << idx_ << endl;
      itr = sy1.end();
      itr--;
    }
    sy1.erase(P(y, idx));

    // cout << i << endl;
  }
  while (sy2.size() > 0) {
    P y = *(--sy2.end());
    int idx = y.second;
    int x = dec[idx].first;
    sy2.erase(--sy2.end());
    auto itr = sx2.begin();
    while ((*itr).second != idx) {
      // cout << (*itr).first << endl;
      unite((*itr).second, idx);
      sx2.erase(itr);
      sy2.erase(P(dec[(*itr).second].second, (*itr).second));
      itr = sx2.begin();
    }
    sx2.erase(P(x, idx));
    // cout << idx << endl;
    // for (auto it = sx2.begin(); it != sx2.end(); it++){
    //     cout << (*it).first << ":" << (*it).second << " ";
    // }cout << endl;
    // for (auto it = sy2.begin(); it != sy2.end(); it++){
    //     cout << (*it).first << ":" << (*it).second << " ";
    // }cout << endl;
    // rep(i, n){
    //     cout << count(i) << endl;
    // }
  }
  // rep(i, n){
  //     cout << num[i] << endl;
  // }
  rep(i, n) { cout << count(i) << endl; }
}


#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <complex>
#include <cstring>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

using namespace std;
// using namespace atcoder;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (int)(n)-1; i >= 0; --i)
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define RFOR(i, a, n) for (int i = (int)(n)-1; i >= (a); --i)

#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()

#define DUMP(x) cerr << #x << " = " << (x) << endl
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "[";
  REP(i, SZ(v)) {
    if (i)
      os << ", ";
    os << v[i];
  }
  return os << "]";
}

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  return os << "(" << p.first << " " << p.second << ")";
}

template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

template <class T> bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return true;
  }
  return false;
}

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvll = vector<vll>;

const ll MOD = 1e9 + 7;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;
const ld eps = 1e-9;

// edit

struct UnionFind {
  vector<int> par, sz;

  UnionFind(int n) : par(n), sz(n, 1) {
    for (int i = 0; i < n; ++i)
      par[i] = i;
  }

  int root(int x) {
    if (par[x] == x)
      return x;
    return par[x] = root(par[x]);
  }

  void merge(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y)
      return;
    if (sz[x] < sz[y])
      swap(x, y);
    par[y] = x;
    sz[x] += sz[y];
    sz[y] = 0;
  }

  bool issame(int x, int y) { return root(x) == root(y); }

  int size(int x) { return sz[root(x)]; }
};

void solve() {
  int N;
  cin >> N;
  vector<pair<int, int>> xy(N);
  vector<pair<int, int>> xi(N);
  REP(i, N) {
    cin >> xy[i].first >> xy[i].second;
    xy[i].first--;
    xy[i].second--;
    xi[i] = {xy[i].first, i};
  }
  sort(ALL(xy));

  vector<int> gmin(N), gmax(N);
  for (int i = 0; i < N; ++i) {
    gmin[i] = xy[i].second;
    gmax[i] = xy[i].second;
  }

  UnionFind uf(N);
  while (true) {
    bool merge = false;
    for (int i = 0; i + 1 < N; ++i) {
      if (uf.issame(i, i + 1)) {
        continue;
      }
      if (gmin[uf.root(i)] < gmax[uf.root(i + 1)]) {
        gmin[uf.root(i)] = min(gmin[uf.root(i)], gmin[uf.root(i + 1)]);
        gmax[uf.root(i)] = max(gmax[uf.root(i)], gmax[uf.root(i + 1)]);

        gmin[uf.root(i + 1)] = gmin[uf.root(i)];
        gmax[uf.root(i + 1)] = gmax[uf.root(i)];

        //                cerr << "merge " << uf.root(i) << " " << uf.root(i +
        //                1) << endl;

        uf.merge(i, i + 1);
        merge = true;
      }
    }

    if (!merge)
      break;
  }
  for (int i = 0; i < N; ++i) {
    cout << uf.size(xi[i].first) << endl;
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  //    std::ifstream in("input.txt");
  //    std::cin.rdbuf(in.rdbuf());

  solve();

  return 0;
}

#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <complex>
#include <cstring>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

using namespace std;
// using namespace atcoder;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (int)(n)-1; i >= 0; --i)
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define RFOR(i, a, n) for (int i = (int)(n)-1; i >= (a); --i)

#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()

#define DUMP(x) cerr << #x << " = " << (x) << endl
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "[";
  REP(i, SZ(v)) {
    if (i)
      os << ", ";
    os << v[i];
  }
  return os << "]";
}

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  return os << "(" << p.first << " " << p.second << ")";
}

template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

template <class T> bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return true;
  }
  return false;
}

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvll = vector<vll>;

const ll MOD = 1e9 + 7;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;
const ld eps = 1e-9;

// edit

struct UnionFind {
  vector<int> par, sz;

  UnionFind(int n) : par(n), sz(n, 1) {
    for (int i = 0; i < n; ++i)
      par[i] = i;
  }

  int root(int x) {
    if (par[x] == x)
      return x;
    return par[x] = root(par[x]);
  }

  void merge(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y)
      return;
    if (sz[x] < sz[y])
      swap(x, y);
    par[y] = x;
    sz[x] += sz[y];
    sz[y] = 0;
  }

  bool issame(int x, int y) { return root(x) == root(y); }

  int size(int x) { return sz[root(x)]; }
};

void solve() {
  int N;
  cin >> N;
  vector<pair<int, int>> xy(N);
  vector<pair<int, int>> xi(N);
  REP(i, N) {
    cin >> xy[i].first >> xy[i].second;
    xy[i].first--;
    xy[i].second--;
    xi[i] = {xy[i].first, i};
  }
  sort(ALL(xy));

  vector<int> gmin(N), gmax(N);
  for (int i = 0; i < N; ++i) {
    gmin[i] = xy[i].second;
    gmax[i] = xy[i].second;
  }

  UnionFind uf(N);
  while (true) {
    bool merge = false;
    for (int i = 0; i + 1 < N; ++i) {
      if (uf.issame(i, i + 1)) {
        continue;
      }
      if (gmin[uf.root(i)] < gmax[uf.root(i + 1)]) {
        gmin[uf.root(i)] = min(gmin[uf.root(i)], gmin[uf.root(i + 1)]);
        gmax[uf.root(i)] = max(gmax[uf.root(i)], gmax[uf.root(i + 1)]);

        gmin[uf.root(i + 1)] = gmin[uf.root(i)];
        gmax[uf.root(i + 1)] = gmax[uf.root(i)];

        //                cerr << "merge " << uf.root(i) << " " << uf.root(i +
        //                1) << endl;

        uf.merge(i, i + 1);
        merge = true;
      }
    }

    for (int i = N - 2; i >= 0; --i) {
      if (uf.issame(i, i + 1)) {
        continue;
      }
      if (gmin[uf.root(i)] < gmax[uf.root(i + 1)]) {
        gmin[uf.root(i)] = min(gmin[uf.root(i)], gmin[uf.root(i + 1)]);
        gmax[uf.root(i)] = max(gmax[uf.root(i)], gmax[uf.root(i + 1)]);

        gmin[uf.root(i + 1)] = gmin[uf.root(i)];
        gmax[uf.root(i + 1)] = gmax[uf.root(i)];

        //                cerr << "merge " << uf.root(i) << " " << uf.root(i +
        //                1) << endl;

        uf.merge(i, i + 1);
        merge = true;
      }
    }
    if (!merge)
      break;
  }
  for (int i = 0; i < N; ++i) {
    cout << uf.size(xi[i].first) << endl;
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  //    std::ifstream in("input.txt");
  //    std::cin.rdbuf(in.rdbuf());

  solve();

  return 0;
}


#include <bits/stdc++.h>

using namespace std;

vector<int> d;

void build(int n) { d.resize(n, -1); }

int find(int x) {
  if (d[x] < 0)
    return x;
  return d[x] = find(d[x]);
}

void merge(int x, int y) {
  x = find(x);
  y = find(y);
  if (x == y)
    return;
  if (d[x] > d[y])
    swap(x, y);
  d[x] += d[y];
  d[y] = x;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  vector<pair<pair<int, int>, int>> p(n);
  for (int i = 0; i < n; ++i) {
    cin >> p[i].first.first >> p[i].first.second;
    p[i].second = i;
  }
  sort(p.begin(), p.end());
  stack<pair<int, int>> st;
  build(n);
  for (int i = 0; i < n; ++i) {
    stack<pair<int, int>> new_st;
    bool suc = false;
    while (!st.empty()) {
      auto t = st.top();
      st.pop();
      new_st.push(t);
      if (t.first < p[i].first.second) {
        merge(p[i].second, t.second);
        suc = true;
      }
    }
    if (!suc) {
      pair<int, int> tt = make_pair(p[i].first.second, p[i].second);
      new_st.push(tt);
    }
    swap(st, new_st);
  }
  vector<int> ans(n);
  for (int i = 0; i < n; ++i) {
    ans[p[i].second] = -d[find(p[i].second)];
  }
  for (int i = 0; i < n; ++i) {
    cout << ans[i] << '\\n';
  }
  return 0;
}

#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  struct P {
    int x, y, index;
  };
  vector<P> p(n);
  for (int i = 0; i < n; ++i) {
    cin >> p[i].x >> p[i].y;
    p[i].index = i;
  }
  sort(p.begin(), p.end(), [](const P a, const P b) { return a.x < b.x; });
  vector<int> ans(n);
  int pre = -1;
  int min_y = n + 1;
  int cnt = 0;
  for (int i = 0; i < n; ++i) {
    if (min_y == n - i + 1) {
      for (int j = i - 1; j > pre; --j) {
        ans[p[j].index] = cnt;
      }
      pre = i - 1;
      cnt = 1;
    } else {
      ++cnt;
    }
    min_y = min(min_y, p[i].y);
  }
  for (int i = n - 1; i > pre; --i) {
    ans[p[i].index] = cnt;
  }
  for (int i = 0; i < n; ++i) {
    cout << ans[i] << '\\n';
  }
  return 0;
}


#include <iostream>
#include <numeric>
#include <set>
#include <vector>
using namespace std;

class UnionFind {
  vector<int> par, rank, size;

public:
  explicit UnionFind(int n) : par(n), rank(n, 0), size(n, 1) {
    iota(par.begin(), par.end(), 0);
  }

  int find(int i) { return (par[i] == i) ? i : (par[i] = find(par[i])); }

  void unite(int i, int j) {
    int x = find(i), y = find(j);
    if (x != y) {
      if (rank[x] < rank[y]) {
        par[x] = y;
        size[y] += size[x];
      } else {
        par[y] = x;
        size[x] += size[y];
        if (rank[x] == rank[y])
          rank[x]++;
      }
    }
  }

  int card(int i) { return size[find(i)]; }
};

int main() {
  int n;
  cin >> n;
  int xy[n], xinv[n];
  for (int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    xy[x - 1] = y - 1;
    xinv[x - 1] = i;
  }
  set<pair<int, int>> s; // (y, x)
  UnionFind uf(n);
  for (int x = 0; x < n; x++) {
    pair<int, int> p = {xy[x], x};
    for (auto it = s.begin(); it != s.end() && it->first < xy[x];) {
      uf.unite(xinv[x], xinv[it->second]);
      it = s.erase(it);
      if (p.second > it->first)
        p = *it;
    }
    s.insert(p);
  }
  for (int i = 0; i < n; i++)
    cout << uf.card(i) << endl;
}

#include <iostream>
#include <numeric>
#include <set>
#include <vector>
using namespace std;

class UnionFind {
  vector<int> par, rank, size;

public:
  explicit UnionFind(int n) : par(n), rank(n, 0), size(n, 1) {
    iota(par.begin(), par.end(), 0);
  }

  int find(int i) { return (par[i] == i) ? i : (par[i] = find(par[i])); }

  void unite(int i, int j) {
    int x = find(i), y = find(j);
    if (x != y) {
      if (rank[x] < rank[y]) {
        par[x] = y;
        size[y] += size[x];
      } else {
        par[y] = x;
        size[x] += size[y];
        if (rank[x] == rank[y])
          rank[x]++;
      }
    }
  }

  int card(int i) { return size[find(i)]; }
};

int main() {
  int n;
  cin >> n;
  int xy[n], xinv[n];
  for (int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    xy[x - 1] = y - 1;
    xinv[x - 1] = i;
  }
  set<pair<int, int>> s; // (y, x)
  UnionFind uf(n);
  for (int x = 0; x < n; x++) {
    pair<int, int> p = {xy[x], x};
    for (auto it = s.begin(); it != s.end() && it->first < xy[x];) {
      uf.unite(xinv[x], xinv[it->second]);
      if (p.first > it->first)
        p = *it;
      it = s.erase(it);
    }
    s.insert(p);
  }
  for (int i = 0; i < n; i++)
    cout << uf.card(i) << endl;
}


/*
Dont BLUNDER
*/

// #pragma GCC optimize("O3")
// #pragma comment(linker, "/stack:200000000")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimization ("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

 */
// #define d long double
#define int long long
#define pii pair<int, int>
#define pb push_back
#define endl '\\n'
#define pi acos(-1)

#define init(x, a) memset(x, a, sizeof(x))
#define all(c) c.begin(), c.end()
int const mod1 = 998244353;
int const mod = 1000000007;
#define bitcount(x) __builtin_popcountll(x)
#define l first
#define r second
const int inf = LLONG_MAX;
int toint(const string &s) {
  stringstream ss;
  ss << s;
  int x;
  ss >> x;
  return x;
}
string tostring(int number) {
  stringstream ss;
  ss << number;
  return ss.str();
}
#define trace1(x) cerr << #x << ": " << x << endl
#define trace2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl
#define trace3(x, y, z)                                                        \\
  cerr << #x << ":" << x << " | " << #y << ": " << y << " | " << #z << ": "    \\
       << z << endl
#define haha                                                                   \\
  ios_base::sync_with_stdio(0);                                                \\
  cin.tie(0);                                                                  \\
  cout.tie(0);
// * Using PBDS *
/*typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update>
               os; */

struct cmp {
  bool operator()(pii a, pii b) { return (a.l < b.l); }
};

int modexp(int x, int n) {
  if (n == 0) {
    return 1;
  } else if (n & 1) {
    return (modexp((x * x) % mod, n / 2) % mod * x % mod) % mod;
  } else {
    return (modexp((x * x) % mod, n / 2) % mod);
  }
}

int modinv(int n) { return modexp(n, mod - 2); }

int gcd(int a, int b) {
  if (b == 0) {
    return a;
  }
  return gcd(b, a % b);
}

bool comp(pair<pii, int> a, pair<pii, int> b) { return a.l.l < b.l.l; }
vector<int> adj[200001];
int vis[200001];
vector<int> cursz;

void dfs(int x) {
  vis[x] = 1;
  cursz.pb(x);
  for (auto i : adj[x]) {
    if (vis[i] == 0) {
      vis[i] = 1;
      dfs(i);
    }
  }
}

signed main() {
  haha
#ifndef ONLINE_JUDGE

      freopen("inp.txt", "r", stdin);

  freopen("out1.txt", "w", stdout);
#endif
  int n;
  cin >> n;
  pair<pii, int> arr[n];
  for (int i = 0; i < n; i++) {
    cin >> arr[i].l.l >> arr[i].l.r;
    arr[i].r = i;
  }
  sort(arr, arr + n, comp);
  stack<pair<pii, int>> st;
  st.push({{arr[0].l.l, arr[0].l.r}, arr[0].r});
  // vis[arr[0].r]=1;
  vector<int> ans(n);
  for (int i = 1; i < n; i++) {
    int x = arr[i].l.l;
    int y = arr[i].l.r;
    int cind = arr[i].r;

    while (st.size() && (y > st.top().l.r)) {
      int ind = st.top().r;
      st.pop();
      adj[ind].pb(cind);
      adj[cind].pb(ind);
    }
    st.push({{x, y}, cind});
  }
  vector<int> check;
  while (st.size()) {
    int t1 = st.top().l.r;
    st.pop();
    check.pb(t1);
  }
  for (int i = 1; i < check.size(); i++) {
    if (check[i] > check[i - 1])
      while (1)
        ;
  }
  for (int i = 0; i < n; i++) {
    if (vis[i] == 0) {
      dfs(i);
      int val = cursz.size();
      for (auto x : cursz) {
        ans[x] = val;
      }
      cursz.clear();
    }
  }
  for (auto x : ans)
    cout << x << " ";
}

/*
Dont BLUNDER
*/

// #pragma GCC optimize("O3")
// #pragma comment(linker, "/stack:200000000")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimization ("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

 */
// #define d long double
#define int long long
#define pii pair<int, int>
#define pb push_back
#define endl '\\n'
#define pi acos(-1)

#define init(x, a) memset(x, a, sizeof(x))
#define all(c) c.begin(), c.end()
int const mod1 = 998244353;
int const mod = 1000000007;
#define bitcount(x) __builtin_popcountll(x)
#define l first
#define r second
const int inf = LLONG_MAX;
int toint(const string &s) {
  stringstream ss;
  ss << s;
  int x;
  ss >> x;
  return x;
}
string tostring(int number) {
  stringstream ss;
  ss << number;
  return ss.str();
}
#define trace1(x) cerr << #x << ": " << x << endl
#define trace2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl
#define trace3(x, y, z)                                                        \\
  cerr << #x << ":" << x << " | " << #y << ": " << y << " | " << #z << ": "    \\
       << z << endl
#define haha                                                                   \\
  ios_base::sync_with_stdio(0);                                                \\
  cin.tie(0);                                                                  \\
  cout.tie(0);
// * Using PBDS *
/*typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update>
               os; */

struct cmp {
  bool operator()(pii a, pii b) { return (a.l < b.l); }
};

int modexp(int x, int n) {
  if (n == 0) {
    return 1;
  } else if (n & 1) {
    return (modexp((x * x) % mod, n / 2) % mod * x % mod) % mod;
  } else {
    return (modexp((x * x) % mod, n / 2) % mod);
  }
}

int modinv(int n) { return modexp(n, mod - 2); }

int gcd(int a, int b) {
  if (b == 0) {
    return a;
  }
  return gcd(b, a % b);
}

bool comp(pair<pii, int> a, pair<pii, int> b) { return a.l.l < b.l.l; }
vector<int> adj[200001];
int vis[200001];
vector<int> cursz;

void dfs(int x) {
  vis[x] = 1;
  cursz.pb(x);
  for (auto i : adj[x]) {
    if (vis[i] == 0) {
      vis[i] = 1;
      dfs(i);
    }
  }
}

signed main() {
  haha
#ifndef ONLINE_JUDGE

      freopen("inp.txt", "r", stdin);

  freopen("out1.txt", "w", stdout);
#endif
  int n;
  cin >> n;
  pair<pii, int> arr[n];
  for (int i = 0; i < n; i++) {
    cin >> arr[i].l.l >> arr[i].l.r;
    arr[i].r = i;
  }
  sort(arr, arr + n, comp);
  stack<pair<pii, int>> st;
  st.push({{arr[0].l.l, arr[0].l.r}, arr[0].r});
  // vis[arr[0].r]=1;
  vector<int> ans(n);
  for (int i = 1; i < n; i++) {
    int x = arr[i].l.l;
    int y = arr[i].l.r;
    int cind = arr[i].r;
    int y1 = y;
    while (st.size() && (y > st.top().l.r)) {
      int ind = st.top().r;
      y1 = min(y1, st.top().l.r);
      st.pop();
      adj[ind].pb(cind);
      adj[cind].pb(ind);
    }
    st.push({{x, y1}, cind});
  }
  for (int i = 0; i < n; i++) {
    if (vis[i] == 0) {
      dfs(i);
      int val = cursz.size();
      for (auto x : cursz) {
        ans[x] = val;
      }
      cursz.clear();
    }
  }
  for (auto x : ans)
    cout << x << " ";
}


#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define LOCAL 1

#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#define dbg(...)                                                               \\
  cout << #__VA_ARGS__ ": [";                                                  \\
  for (auto e : __VA_ARGS__) {                                                 \\
    cout << e << ", ";                                                         \\
  }                                                                            \\
  cout << "]\\n"
#define dbg1(...) cout << #__VA_ARGS__ " " << __VA_ARGS__
#else
#define dbg(...) 1;
#define dbg1(...) 1;
#endif

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
constexpr ll R = 2e5 + 69, INF = 2e9 + 6969;

int n;
PII t[R];
int ile[R], rep[R];

int Find(int a) {
  if (a != rep[a])
    rep[a] = Find(rep[a]);
  return rep[a];
}
void Union(int a, int b) {
  if (ile[a] < ile[b])
    swap(a, b);
  ile[a] += ile[b];
  rep[b] = Find(a);
}

int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    ile[i] = 1;
    rep[i] = i;
    scanf("%d%d", &t[i].fi, &t[i].se);
  }
  for (int i = 1; i <= n; ++i) {
    int ans = 0;
    for (int j = 1; j <= n; ++j) {
      if (Find(i) == Find(j))
        continue;
      if (t[i].fi < t[j].fi && t[i].se < t[j].se) {
        Union(Find(i), Find(j));
      }
      //  if(t[j].fi < t[i].fi && t[j].se < t[i].se) ans++;
    }
    //  printf("%d\\n", ans+1);
  }
  for (int i = 1; i <= n; ++i)
    printf("%d\\n", ile[Find(i)]);
  return 0;
}

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define LOCAL 1

#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#define dbg(...)                                                               \\
  cout << #__VA_ARGS__ ": [";                                                  \\
  for (auto e : __VA_ARGS__) {                                                 \\
    cout << e << ", ";                                                         \\
  }                                                                            \\
  cout << "]\\n"
#define dbg1(...) cout << #__VA_ARGS__ " " << __VA_ARGS__
#else
#define dbg(...) 1;
#define dbg1(...) 1;
#endif

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
constexpr ll R = 2e5 + 69, INF = 2e9 + 6969;

int n, rep[R], ile[R], X[R], t[R], c[R], Y[R];

int Find(int a) {
  if (a != rep[a])
    rep[a] = Find(rep[a]);
  return rep[a];
}
void Union(int a, int b) {
  a = Find(a);
  b = Find(b);
  if (ile[a] < ile[b])
    swap(a, b);
  if (c[a] > c[b])
    c[a] = c[b];
  ile[a] += ile[b];
  rep[b] = a;
}

stack<PII> s;

int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    int a, b;
    scanf("%d%d", &a, &b);
    t[a] = i;
    Y[b] = i;
    X[a] = b;
    c[i] = b;
    ile[i] = 1;
    rep[i] = i;
  }
  s.push(mp(INF, 0));
  for (int i = 1; i <= n; ++i) {
    while (s.top().fi < X[i]) {
      if (Find(s.top().se) != Find(t[i])) {
        Union(s.top().se, t[i]);
        //  printf("Un: %d %d\\n", s.top().se, t[i]);
      }
      s.pop();
    }
    s.push(mp(c[Find(t[i])], Find(t[i])));
  }
  for (int i = 1; i <= n; ++i) {
    //  printf("%d: %d %d\\n", i, ile[Find(i)], rep[Find(i)]);
    printf("%d\\n", ile[Find(i)]);
  }
  return 0;
}


// Original Code:
// #include <self/utility>
// #include <self/debug>
// #include <self/dsu>
// using namespace std;
//
// struct SegmentTreeMinChange//[)
//{
//     typedef pii T;
//	const T maxValue=mp(inf,-1);
//     const T minValue=mp(-inf,-1);
//	T* dataMax;
//     T* dataMin;
//	T* tag;
//	int nn;
//	int size()
//	{
//		return nn;
//	}
//	void init(int size)
//	{
//		nn=1;
//		while(nn<size)
//		{
//			nn<<=1;
//		}
//		dataMax=new T[nn*2+5];
//         dataMin=new T[nn*2+5];
//		for(int i=0;i<=nn*2;i++)
//		{
//			dataMin[i]=maxValue;
//             dataMax[i]=minValue;
//		}
//	}
//	void build(int a[],int len)
//	{
//		for(int i=0;i<len;i++)
//		{
//			dataMax[i+nn]=mp(a[i],i);
//             dataMin[i+nn]=mp(a[i],i);
//		}
//		for(int i=nn-1;i>=1;i--)
//		{
//			dataMin[i]=min(dataMin[i*2],dataMin[i*2+1]);
//             dataMax[i]=max(dataMax[i*2],dataMax[i*2+1]);
//		}
//	}
//	void erase(int pos)
//	{
//		erase(1,0,nn,pos,pos+1);
//	}
//	void erase(int x,int l,int r,int ql,int qr)
//	{
//		if(l>=qr || r<=ql) return;
//		if(l>=ql && r<=qr)
//		{
//			dataMax[x]=minValue;
//             dataMin[x]=maxValue;
//			return;
//		}
//		erase(x*2,l,l+r>>1,ql,qr);
//		erase(x*2+1,l+r>>1,r,ql,qr);
//		dataMin[x]=min(dataMin[x*2],dataMin[x*2+1]);
//         dataMax[x]=max(dataMax[x*2],dataMax[x*2+1]);
//	}
//     pair <T,T> query(int x,int l,int r,int ql,int qr)
//     {
//         if(r<=ql || l>=qr) return mp(maxValue,minValue);
//         if(l>=ql && r<=qr)
//         {
//             return mp(dataMin[x],dataMax[x]);
//         }
//         pair<T,T> o1=query(x*2,l,l+r>>1,ql,qr);
//         pair<T,T> o2=query(x*2+1,l+r>>1,r,ql,qr);
//         return mp(min(o1.first,o2.first),max(o1.second,o2.second));
//     }
//     inline pair<T,T> query(int l,int r)
//     {
//         return query(1,0,nn,l,r);
//     }
// }sgt;
// DSU dsu;
//
// int n;
// int a[200005];
// int b[200005];
// vector <pair<pii,int> > vSort;
// int dpa[200005];
// int dpb[200005];
// int ans[200005];
// int h[200005];
//
// int main()
//{
//	freopen("input.txt","r",stdin);
//     cin>>n;
//     for(int i=0;i<n;i++)
//     {
//         scanf("%d%d",a+i,b+i);
//         a[i]--;
//         b[i]--;
//     }
//     for(int i=0;i<n;i++)
//     {
//         vSort.push_back(mp(mp(a[i],b[i]),i));
//     }
//     sort(all(vSort));
//     for(int i=0;i<n;i++)
//     {
//         h[i]=vSort[i].first.second;
//     }
//     dsu.init(n);
//     sgt.init(n);
//     sgt.build(h,n);
//     for(int i=0;i<n;i++)
//     {
//         while(true)
//         {
//             pii mv=sgt.query(0,i).first;
//             // cout<<mv.first<<' '<<h[i]<<endl;
//             if(mv.first>=h[i]) break;
//             // cout<<mv.second<<' '<<i<<endl;
//             sgt.erase(mv.second);
//             dsu.merge(mv.second,i);
//         }
//     }
//     for(int i=0;i<n;i++)
//     {
//         ans[vSort[i].second]=dsu.getSize(i);
//     }
//     for(int i=0;i<n;i++)
//     {
//         printf("%d\\n",ans[i]);
//     }
//	return 0;
// }

// substituted with C++ Inliner
#ifndef _SELF_UTILITY
#define _SELF_UTILITY 1
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <vector>
#define Endl endl
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define over(A)                                                                \\
  {                                                                            \\
    cout << A << endl;                                                         \\
    exit(0);                                                                   \\
  }
#define all(A) A.begin(), A.end()
#define quickcin ios_base::sync_with_stdio(false);
const int mod = 998244353;
const int gmod = 2;
const int inf = 1039074182;
const ll llinf = 1LL * inf * inf;
template <typename T1, typename T2> inline void chmin(T1 &x, T2 b) {
  if (b < x)
    x = b;
}
template <typename T1, typename T2> inline void chmax(T1 &x, T2 b) {
  if (b > x)
    x = b;
}
template <typename T1, typename T2> inline void chadd(T1 &x, T2 b) {
  x += b;
  if (x >= mod)
    x -= mod;
}
template <typename T1, typename T2> inline void chmul(T1 &x, T2 b) {
  x = 1LL * x * b % mod;
}
template <typename T1, typename T2> inline void chmod(T1 &x, T2 b) {
  x %= b, x += b;
  if (x >= b)
    x -= b;
}
#endif

#ifndef _SELF_DEBUG
#define _SELF_DEBUG 1
#ifndef _SELF_OPERATOR
#define _SELF_OPERATOR 1
using namespace std;
template <typename T> ostream &operator<<(ostream &cout, vector<T> vec) {
  cout << "{";
  for (int i = 0; i < (int)vec.size(); i++) {
    cout << vec[i];
    if (i != (int)vec.size() - 1)
      cout << ',';
  }
  cout << "}";
  return cout;
}

template <typename T1, typename T2>
ostream &operator<<(ostream &cout, pair<T1, T2> p) {
  cout << "(" << p.first << ',' << p.second << ")";
  return cout;
}

template <typename T, typename T2>
ostream &operator<<(ostream &cout, set<T, T2> s) {
  vector<T> t;
  for (auto x : s)
    t.push_back(x);
  cout << t;
  return cout;
}

template <typename T> ostream &operator<<(ostream &cout, multiset<T> s) {
  vector<T> t;
  for (auto x : s)
    t.push_back(x);
  cout << t;
  return cout;
}

template <typename T> ostream &operator<<(ostream &cout, queue<T> q) {
  vector<T> t;
  while (q.size()) {
    t.push_back(q.front());
    q.pop();
  }
  cout << t;
  return cout;
}

template <typename T1, typename T2>
ostream &operator<<(ostream &cout, map<T1, T2> m) {
  for (auto &x : m) {
    cout << "Key: " << x.first << ' ' << "Value: " << x.second << endl;
  }
  return cout;
}

template <typename T> T operator*(vector<T> v1, vector<T> v2) {
  assert(v1.size() == v2.size());
  int n = v1.size();
  T res = 0;
  for (int i = 0; i < n; i++) {
    res += v1[i] * v2[i];
  }
  return res;
}

template <typename T1, typename T2>
pair<T1, T2> operator+(pair<T1, T2> x, pair<T1, T2> y) {
  return make_pair(x.first + y.first, x.second + y.second);
}

template <typename T1, typename T2>
void operator+=(pair<T1, T2> &x, pair<T1, T2> y) {
  x.first += y.first;
  x.second += y.second;
}

template <typename T1, typename T2> pair<T1, T2> operator-(pair<T1, T2> x) {
  return make_pair(-x.first, -x.second);
}

template <typename T> vector<vector<T>> operator~(vector<vector<T>> vec) {
  vector<vector<T>> v;
  int n = vec.size(), m = vec[0].size();
  v.resize(m);
  for (int i = 0; i < m; i++) {
    v[i].resize(n);
  }
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < n; j++) {
      v[i][j] = vec[j][i];
    }
  }
  return v;
}
#endif

void print0x(int x) {
  std::vector<int> vec;
  while (x) {
    vec.push_back(x & 1);
    x >>= 1;
  }
  std::reverse(vec.begin(), vec.end());
  for (int i = 0; i < (int)vec.size(); i++) {
    std::cout << vec[i];
  }
  std::cout << ' ';
}

template <typename T> void print0x(T x, int len) {
  std::vector<int> vec;
  while (x) {
    vec.push_back(x & 1);
    x >>= 1;
  }
  reverse(vec.begin(), vec.end());
  for (int i = vec.size(); i < len; i++) {
    putchar('0');
  }
  for (int i = 0; i < vec.size(); i++) {
    std::cout << vec[i];
  }
  std::cout << ' ';
}
#endif
struct DSU {
  int *f;
  int *depth;
  int *sz;
  inline void clear(int n) {
    for (int i = 0; i < n; i++) {
      f[i] = i;
      depth[i] = 1;
      sz[i] = 1;
    }
  }
  inline int init(int n) {
    f = new int[n + 5];
    depth = new int[n + 5];
    sz = new int[n + 5];
    clear(n);
  }
  inline int find(int x) { return (f[x] == x ? x : f[x] = find(f[x])); }
  inline int getSize(int x) { return sz[find(x)]; }
  inline void merge(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y)
      return;
    if (depth[x] > depth[y]) {
      f[y] = x;
      sz[x] += sz[y];
    } else if (depth[y] > depth[x]) {
      f[x] = y;
      sz[y] += sz[x];
    } else {
      sz[y] += sz[x];
      f[x] = y;
      depth[y]++;
    }
  }
};
using namespace std;

struct SegmentTreeMinChange //[)
{
  typedef pii T;
  const T maxValue = mp(inf, -1);
  const T minValue = mp(-inf, -1);
  T *dataMax;
  T *dataMin;
  T *tag;
  int nn;
  int size() { return nn; }
  void init(int size) {
    nn = 1;
    while (nn < size) {
      nn <<= 1;
    }
    dataMax = new T[nn * 2 + 5];
    dataMin = new T[nn * 2 + 5];
    for (int i = 0; i <= nn * 2; i++) {
      dataMin[i] = maxValue;
      dataMax[i] = minValue;
    }
  }
  void build(int a[], int len) {
    for (int i = 0; i < len; i++) {
      dataMax[i + nn] = mp(a[i], i);
      dataMin[i + nn] = mp(a[i], i);
    }
    for (int i = nn - 1; i >= 1; i--) {
      dataMin[i] = min(dataMin[i * 2], dataMin[i * 2 + 1]);
      dataMax[i] = max(dataMax[i * 2], dataMax[i * 2 + 1]);
    }
  }
  void erase(int pos) { erase(1, 0, nn, pos, pos + 1); }
  void erase(int x, int l, int r, int ql, int qr) {
    if (l >= qr || r <= ql)
      return;
    if (l >= ql && r <= qr) {
      dataMax[x] = minValue;
      dataMin[x] = maxValue;
      return;
    }
    erase(x * 2, l, l + r >> 1, ql, qr);
    erase(x * 2 + 1, l + r >> 1, r, ql, qr);
    dataMin[x] = min(dataMin[x * 2], dataMin[x * 2 + 1]);
    dataMax[x] = max(dataMax[x * 2], dataMax[x * 2 + 1]);
  }
  pair<T, T> query(int x, int l, int r, int ql, int qr) {
    if (r <= ql || l >= qr)
      return mp(maxValue, minValue);
    if (l >= ql && r <= qr) {
      return mp(dataMin[x], dataMax[x]);
    }
    pair<T, T> o1 = query(x * 2, l, l + r >> 1, ql, qr);
    pair<T, T> o2 = query(x * 2 + 1, l + r >> 1, r, ql, qr);
    return mp(min(o1.first, o2.first), max(o1.second, o2.second));
  }
  inline pair<T, T> query(int l, int r) { return query(1, 0, nn, l, r); }
} sgt;
DSU dsu;

int n;
int a[200005];
int b[200005];
vector<pair<pii, int>> vSort;
int dpa[200005];
int dpb[200005];
int ans[200005];
int h[200005];

int main() {
  //	freopen("input.txt","r",stdin);
  cin >> n;
  for (int i = 0; i < n; i++) {
    scanf("%d%d", a + i, b + i);
    a[i]--;
    b[i]--;
  }
  for (int i = 0; i < n; i++) {
    vSort.push_back(mp(mp(a[i], b[i]), i));
  }
  sort(all(vSort));
  for (int i = 0; i < n; i++) {
    h[i] = vSort[i].first.second;
  }
  dsu.init(n);
  sgt.init(n);
  sgt.build(h, n);
  for (int i = 0; i < n; i++) {
    while (true) {
      pii mv = sgt.query(0, i).first;
      // cout<<mv.first<<' '<<h[i]<<endl;
      if (mv.first >= h[i])
        break;
      // cout<<mv.second<<' '<<i<<endl;
      sgt.erase(mv.second);
      dsu.merge(mv.second, i);
    }
  }
  for (int i = 0; i < n; i++) {
    ans[vSort[i].second] = dsu.getSize(i);
  }
  for (int i = 0; i < n; i++) {
    printf("%d\\n", ans[i]);
  }
  return 0;
}

// Original Code:
// #include <self/utility>
// #include <self/debug>
// #include <self/dsu>
// using namespace std;
//
// struct SegmentTreeMinChange//[)
//{
//     typedef pii T;
//	const T maxValue=mp(inf,-1);
//     const T minValue=mp(-inf,-1);
//	T* dataMax;
//     T* dataMin;
//	T* tag;
//	int nn;
//	int size()
//	{
//		return nn;
//	}
//	void init(int size)
//	{
//		nn=1;
//		while(nn<size)
//		{
//			nn<<=1;
//		}
//		dataMax=new T[nn*2+5];
//         dataMin=new T[nn*2+5];
//		for(int i=0;i<=nn*2;i++)
//		{
//			dataMin[i]=maxValue;
//             dataMax[i]=minValue;
//		}
//	}
//	void build(int a[],int len)
//	{
//		for(int i=0;i<len;i++)
//		{
//			dataMax[i+nn]=mp(a[i],i);
//             dataMin[i+nn]=mp(a[i],i);
//		}
//		for(int i=nn-1;i>=1;i--)
//		{
//			dataMin[i]=min(dataMin[i*2],dataMin[i*2+1]);
//             dataMax[i]=max(dataMax[i*2],dataMax[i*2+1]);
//		}
//	}
//	void erase(int pos)
//	{
//		erase(1,0,nn,pos,pos+1);
//	}
//	void erase(int x,int l,int r,int ql,int qr)
//	{
//		if(l>=qr || r<=ql) return;
//		if(l>=ql && r<=qr)
//		{
//			dataMax[x]=minValue;
//             dataMin[x]=maxValue;
//			return;
//		}
//		erase(x*2,l,l+r>>1,ql,qr);
//		erase(x*2+1,l+r>>1,r,ql,qr);
//		dataMin[x]=min(dataMin[x*2],dataMin[x*2+1]);
//         dataMax[x]=max(dataMax[x*2],dataMax[x*2+1]);
//	}
//     pair <T,T> query(int x,int l,int r,int ql,int qr)
//     {
//         if(r<=ql || l>=qr) return mp(maxValue,minValue);
//         if(l>=ql && r<=qr)
//         {
//             return mp(dataMin[x],dataMax[x]);
//         }
//         pair<T,T> o1=query(x*2,l,l+r>>1,ql,qr);
//         pair<T,T> o2=query(x*2+1,l+r>>1,r,ql,qr);
//         return mp(min(o1.first,o2.first),max(o1.second,o2.second));
//     }
//     inline pair<T,T> query(int l,int r)
//     {
//         return query(1,0,nn,l,r);
//     }
// }sgt;
// DSU dsu;
//
// int n;
// int a[200005];
// int b[200005];
// vector <pair<pii,int> > vSort;
// int dpa[200005];
// int dpb[200005];
// int ans[200005];
// int h[200005];
// int visit[200005];
//
// void dfs(int x)
//{
//	visit[x]=true;
//     while(true)
//     {
//         pii mv=sgt.query(0,x).first;
//         if(mv.first>=h[x]) break;
//         sgt.erase(mv.second);
//         dsu.merge(mv.second,x);
//         dfs(mv.second);
//     }
//     while(true)
//     {
//         pii mv=sgt.query(x+1,n).second;
//         if(mv.first<=h[x]) break;
//         sgt.erase(mv.second);
//         dsu.merge(mv.second,x);
//         dfs(mv.second);
//     }
// }
//
// int main()
//{
//	// freopen("input.txt","r",stdin);
//     cin>>n;
//     for(int i=0;i<n;i++)
//     {
//         scanf("%d%d",a+i,b+i);
//         a[i]--;
//         b[i]--;
//     }
//     for(int i=0;i<n;i++)
//     {
//         vSort.push_back(mp(mp(a[i],b[i]),i));
//     }
//     sort(all(vSort));
//     for(int i=0;i<n;i++)
//     {
//         h[i]=vSort[i].first.second;
//     }
//     dsu.init(n);
//     sgt.init(n);
//     sgt.build(h,n);
//
//     for(int i=0;i<n;i++)
//     {
//     	if(!visit[i]) dfs(i);
//	}
//
//     for(int i=0;i<n;i++)
//     {
//         ans[vSort[i].second]=dsu.getSize(i);
//     }
//     for(int i=0;i<n;i++)
//     {
//         printf("%d\\n",ans[i]);
//     }
//	return 0;
// }

// substituted with C++ Inliner
#ifndef _SELF_UTILITY
#define _SELF_UTILITY 1
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <vector>
#define Endl endl
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define over(A)                                                                \\
  {                                                                            \\
    cout << A << endl;                                                         \\
    exit(0);                                                                   \\
  }
#define all(A) A.begin(), A.end()
#define quickcin ios_base::sync_with_stdio(false);
const int mod = 998244353;
const int gmod = 2;
const int inf = 1039074182;
const ll llinf = 1LL * inf * inf;
template <typename T1, typename T2> inline void chmin(T1 &x, T2 b) {
  if (b < x)
    x = b;
}
template <typename T1, typename T2> inline void chmax(T1 &x, T2 b) {
  if (b > x)
    x = b;
}
template <typename T1, typename T2> inline void chadd(T1 &x, T2 b) {
  x += b;
  if (x >= mod)
    x -= mod;
}
template <typename T1, typename T2> inline void chmul(T1 &x, T2 b) {
  x = 1LL * x * b % mod;
}
template <typename T1, typename T2> inline void chmod(T1 &x, T2 b) {
  x %= b, x += b;
  if (x >= b)
    x -= b;
}
#endif

#ifndef _SELF_DEBUG
#define _SELF_DEBUG 1
#ifndef _SELF_OPERATOR
#define _SELF_OPERATOR 1
using namespace std;
template <typename T> ostream &operator<<(ostream &cout, vector<T> vec) {
  cout << "{";
  for (int i = 0; i < (int)vec.size(); i++) {
    cout << vec[i];
    if (i != (int)vec.size() - 1)
      cout << ',';
  }
  cout << "}";
  return cout;
}

template <typename T1, typename T2>
ostream &operator<<(ostream &cout, pair<T1, T2> p) {
  cout << "(" << p.first << ',' << p.second << ")";
  return cout;
}

template <typename T, typename T2>
ostream &operator<<(ostream &cout, set<T, T2> s) {
  vector<T> t;
  for (auto x : s)
    t.push_back(x);
  cout << t;
  return cout;
}

template <typename T> ostream &operator<<(ostream &cout, multiset<T> s) {
  vector<T> t;
  for (auto x : s)
    t.push_back(x);
  cout << t;
  return cout;
}

template <typename T> ostream &operator<<(ostream &cout, queue<T> q) {
  vector<T> t;
  while (q.size()) {
    t.push_back(q.front());
    q.pop();
  }
  cout << t;
  return cout;
}

template <typename T1, typename T2>
ostream &operator<<(ostream &cout, map<T1, T2> m) {
  for (auto &x : m) {
    cout << "Key: " << x.first << ' ' << "Value: " << x.second << endl;
  }
  return cout;
}

template <typename T> T operator*(vector<T> v1, vector<T> v2) {
  assert(v1.size() == v2.size());
  int n = v1.size();
  T res = 0;
  for (int i = 0; i < n; i++) {
    res += v1[i] * v2[i];
  }
  return res;
}

template <typename T1, typename T2>
pair<T1, T2> operator+(pair<T1, T2> x, pair<T1, T2> y) {
  return make_pair(x.first + y.first, x.second + y.second);
}

template <typename T1, typename T2>
void operator+=(pair<T1, T2> &x, pair<T1, T2> y) {
  x.first += y.first;
  x.second += y.second;
}

template <typename T1, typename T2> pair<T1, T2> operator-(pair<T1, T2> x) {
  return make_pair(-x.first, -x.second);
}

template <typename T> vector<vector<T>> operator~(vector<vector<T>> vec) {
  vector<vector<T>> v;
  int n = vec.size(), m = vec[0].size();
  v.resize(m);
  for (int i = 0; i < m; i++) {
    v[i].resize(n);
  }
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < n; j++) {
      v[i][j] = vec[j][i];
    }
  }
  return v;
}
#endif

void print0x(int x) {
  std::vector<int> vec;
  while (x) {
    vec.push_back(x & 1);
    x >>= 1;
  }
  std::reverse(vec.begin(), vec.end());
  for (int i = 0; i < (int)vec.size(); i++) {
    std::cout << vec[i];
  }
  std::cout << ' ';
}

template <typename T> void print0x(T x, int len) {
  std::vector<int> vec;
  while (x) {
    vec.push_back(x & 1);
    x >>= 1;
  }
  reverse(vec.begin(), vec.end());
  for (int i = vec.size(); i < len; i++) {
    putchar('0');
  }
  for (int i = 0; i < vec.size(); i++) {
    std::cout << vec[i];
  }
  std::cout << ' ';
}
#endif
struct DSU {
  int *f;
  int *depth;
  int *sz;
  inline void clear(int n) {
    for (int i = 0; i < n; i++) {
      f[i] = i;
      depth[i] = 1;
      sz[i] = 1;
    }
  }
  inline void init(int n) {
    f = new int[n + 5];
    depth = new int[n + 5];
    sz = new int[n + 5];
    clear(n);
  }
  inline int find(int x) { return (f[x] == x ? x : f[x] = find(f[x])); }
  inline int getSize(int x) { return sz[find(x)]; }
  inline void merge(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y)
      return;
    if (depth[x] > depth[y]) {
      f[y] = x;
      sz[x] += sz[y];
    } else if (depth[y] > depth[x]) {
      f[x] = y;
      sz[y] += sz[x];
    } else {
      sz[y] += sz[x];
      f[x] = y;
      depth[y]++;
    }
  }
};
using namespace std;

struct SegmentTreeMinChange //[)
{
  typedef pii T;
  const T maxValue = mp(inf, -1);
  const T minValue = mp(-inf, -1);
  T *dataMax;
  T *dataMin;
  T *tag;
  int nn;
  int size() { return nn; }
  void init(int size) {
    nn = 1;
    while (nn < size) {
      nn <<= 1;
    }
    dataMax = new T[nn * 2 + 5];
    dataMin = new T[nn * 2 + 5];
    for (int i = 0; i <= nn * 2; i++) {
      dataMin[i] = maxValue;
      dataMax[i] = minValue;
    }
  }
  void build(int a[], int len) {
    for (int i = 0; i < len; i++) {
      dataMax[i + nn] = mp(a[i], i);
      dataMin[i + nn] = mp(a[i], i);
    }
    for (int i = nn - 1; i >= 1; i--) {
      dataMin[i] = min(dataMin[i * 2], dataMin[i * 2 + 1]);
      dataMax[i] = max(dataMax[i * 2], dataMax[i * 2 + 1]);
    }
  }
  void erase(int pos) { erase(1, 0, nn, pos, pos + 1); }
  void erase(int x, int l, int r, int ql, int qr) {
    if (l >= qr || r <= ql)
      return;
    if (l >= ql && r <= qr) {
      dataMax[x] = minValue;
      dataMin[x] = maxValue;
      return;
    }
    erase(x * 2, l, l + r >> 1, ql, qr);
    erase(x * 2 + 1, l + r >> 1, r, ql, qr);
    dataMin[x] = min(dataMin[x * 2], dataMin[x * 2 + 1]);
    dataMax[x] = max(dataMax[x * 2], dataMax[x * 2 + 1]);
  }
  pair<T, T> query(int x, int l, int r, int ql, int qr) {
    if (r <= ql || l >= qr)
      return mp(maxValue, minValue);
    if (l >= ql && r <= qr) {
      return mp(dataMin[x], dataMax[x]);
    }
    pair<T, T> o1 = query(x * 2, l, l + r >> 1, ql, qr);
    pair<T, T> o2 = query(x * 2 + 1, l + r >> 1, r, ql, qr);
    return mp(min(o1.first, o2.first), max(o1.second, o2.second));
  }
  inline pair<T, T> query(int l, int r) { return query(1, 0, nn, l, r); }
} sgt;
DSU dsu;

int n;
int a[200005];
int b[200005];
vector<pair<pii, int>> vSort;
int dpa[200005];
int dpb[200005];
int ans[200005];
int h[200005];
int visit[200005];

void dfs(int x) {
  visit[x] = true;
  while (true) {
    pii mv = sgt.query(0, x).first;
    if (mv.first >= h[x])
      break;
    sgt.erase(mv.second);
    dsu.merge(mv.second, x);
    dfs(mv.second);
  }
  while (true) {
    pii mv = sgt.query(x + 1, n).second;
    if (mv.first <= h[x])
      break;
    sgt.erase(mv.second);
    dsu.merge(mv.second, x);
    dfs(mv.second);
  }
}

int main() {
  // freopen("input.txt","r",stdin);
  cin >> n;
  for (int i = 0; i < n; i++) {
    scanf("%d%d", a + i, b + i);
    a[i]--;
    b[i]--;
  }
  for (int i = 0; i < n; i++) {
    vSort.push_back(mp(mp(a[i], b[i]), i));
  }
  sort(all(vSort));
  for (int i = 0; i < n; i++) {
    h[i] = vSort[i].first.second;
  }
  dsu.init(n);
  sgt.init(n);
  sgt.build(h, n);

  for (int i = 0; i < n; i++) {
    if (!visit[i])
      dfs(i);
  }

  for (int i = 0; i < n; i++) {
    ans[vSort[i].second] = dsu.getSize(i);
  }
  for (int i = 0; i < n; i++) {
    printf("%d\\n", ans[i]);
  }
  return 0;
}


#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define repi(i, a, b) for (ll i = (a); i < (b); ++i)
#define rep(i, a) repi(i, 0, a)
#define repdi(i, a, b) for (ll i = (a)-1; i >= (b); --i)
#define repd(i, a) repdi(i, a, 0)
#define itr(it, a) for (auto it = (a).begin(); it != (a).end(); ++it)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define endl '\\n'
#define debug(x) std::cerr << #x << " = " << (x) << endl;

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll << 60;

template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

template <class S, class T>
std::ostream &operator<<(std::ostream &out, const std::pair<S, T> &a) {
  std::cout << '(' << a.first << ", " << a.second << ')';
  return out;
}

ll N;

template <typename T> struct BIT {
  int n;
  std::vector<T> d;
  BIT(int n = 0) : n(n), d(n + 1) {}
  void add(int i, T x = 1) {
    for (i++; i <= n; i += i & -i) {
      d[i] += x;
    }
  }
  T sum(int i) {
    T x = 0;
    for (i++; i; i -= i & -i) {
      x += d[i];
    }
    return x;
  }
  T sum(int l, int r) { return sum(r - 1) - sum(l - 1); }
};

using Tup = std::tuple<ll, ll, ll>;

struct UnionFind {
  std::vector<int> d;
  UnionFind(int n = 0) : d(n, -1) {}
  int find(int x) {
    if (d[x] < 0)
      return x;
    return d[x] = find(d[x]);
  }
  bool unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y)
      return false;
    if (d[x] > d[y])
      std::swap(x, y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return find(x) == find(y); }
  int size(int x) { return -d[find(x)]; }
};

UnionFind uf(200010);

void solve(const std::vector<ll> &x, const std::vector<ll> &y) {
  std::vector<Tup> ps;

  rep(i, N) ps.emplace_back(x[i], y[i], i);

  std::sort(all(ps));

  std::set<P> prs;

  rep(i, N) {
    auto [px, py, pi] = ps[i];

    if (!prs.empty()) {
      auto bound = prs.lower_bound(P(-py, -INF));

      for (auto it = bound; it != prs.end(); ++it) {
        uf.unite(it->second, pi);
      }
    }

    prs.emplace(-py, pi);
  }

  return;
}

int main() {
  std::cin >> N;

  std::vector<ll> x(N), y(N);

  rep(i, N) {
    std::cin >> x[i] >> y[i];
    --x[i];
    --y[i];
  }

  solve(x, y);

  rep(i, N) {
    x[i] = N - 1 - x[i];
    y[i] = N - 1 - y[i];
  }

  rep(i, N) { std::cout << uf.size(i) << endl; }

  return 0;
}

#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define repi(i, a, b) for (ll i = (a); i < (b); ++i)
#define rep(i, a) repi(i, 0, a)
#define repdi(i, a, b) for (ll i = (a)-1; i >= (b); --i)
#define repd(i, a) repdi(i, a, 0)
#define itr(it, a) for (auto it = (a).begin(); it != (a).end(); ++it)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define endl '\\n'
#define debug(x) std::cerr << #x << " = " << (x) << endl;

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll << 60;

template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

template <class S, class T>
std::ostream &operator<<(std::ostream &out, const std::pair<S, T> &a) {
  std::cout << '(' << a.first << ", " << a.second << ')';
  return out;
}

ll N;

template <typename T> struct BIT {
  int n;
  std::vector<T> d;
  BIT(int n = 0) : n(n), d(n + 1) {}
  void add(int i, T x = 1) {
    for (i++; i <= n; i += i & -i) {
      d[i] += x;
    }
  }
  T sum(int i) {
    T x = 0;
    for (i++; i; i -= i & -i) {
      x += d[i];
    }
    return x;
  }
  T sum(int l, int r) { return sum(r - 1) - sum(l - 1); }
};

using Tup = std::tuple<ll, ll, ll>;

struct UnionFind {
  std::vector<int> d;
  UnionFind(int n = 0) : d(n, -1) {}
  int find(int x) {
    if (d[x] < 0)
      return x;
    return d[x] = find(d[x]);
  }
  bool unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y)
      return false;
    if (d[x] > d[y])
      std::swap(x, y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return find(x) == find(y); }
  int size(int x) { return -d[find(x)]; }
};

UnionFind uf(200010);

ll ip[200010];

int main() {
  std::cin >> N;

  std::vector<ll> x(N), y(N);

  std::vector<Tup> ts;

  rep(i, N) {
    std::cin >> x[i] >> y[i];
    --x[i];
    --y[i];

    ts.emplace_back(x[i], y[i], i);

    ip[y[i]] = i;
  }

  std::sort(all(ts));

  std::set<ll> S;

  rep(i, N) {
    auto [tx, ty, ti] = ts[i];

    auto it = S.begin();
    auto ub = S.upper_bound(ty);

    if (it == ub) {
      S.emplace(ty);

      continue;
    }

    ll mi = *it;

    for (; it != ub;) {
      uf.unite(ip[*it], ti);
      it = S.erase(it);
    }

    S.emplace(mi);
  }

  rep(i, N) std::cout << uf.size(i) << endl;

  return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
typedef long long int ll;
typedef long double ld;
typedef pair<ll, ll> p2;
#define sz(a) ll(a.size())
ll x[200005], y[200005], ind[200005], par[200005], sz[200005];
bool comp(ll i, ll j) { return x[i] < x[j]; }
ll find(ll i) {
  if (par[i] == i)
    return i;
  return par[i] = find(par[i]);
}
void merge(ll x, ll y) {
  x = find(x), y = find(y);
  if (x == y)
    return;
  if (sz[x] < sz[y])
    swap(x, y);
  par[y] = x;
  sz[x] += sz[y];
}
void solve() {
  ll n;
  cin >> n;
  for (ll i = 1; i <= n; i++) {
    cin >> x[i] >> y[i];
    ind[i] = i;
    par[i] = i;
    sz[i] = 1;
  }
  sort(ind + 1, ind + n + 1, comp);
  set<p2> s;
  for (ll i = 1; i <= n; i++)
    s.insert({y[ind[i]], ind[i]});
  for (ll qc = 1; qc <= n; qc++) {
    ll i = ind[qc];
    auto it = s.find({y[i], i});
    if (it == s.end())
      continue;
    s.erase(it);
    it = s.lower_bound({y[i] + 1, 0});
    if (s.empty())
      continue;
    set<p2> dum;
    while (it != s.end()) {
      merge(i, it->second);
      it++;
    }
    for (auto ut = dum.begin(); ut != dum.end(); ut++)
      s.erase(*ut);
  }
  for (ll i = 1; i <= n; i++)
    cout << sz[find(i)] << "\\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  clock_t z = clock();
  ll qc = 1;
  // cin>>qc;
  for (ll i = 1; i <= qc; i++) {
    solve();
  }
  debug("Total Time:%.4Lf\\n", (ld)(clock() - z) / CLOCKS_PER_SEC);
}

#include <bits/stdc++.h>
using namespace std;
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
typedef long long int ll;
typedef long double ld;
typedef pair<ll, ll> p2;
#define sz(a) ll(a.size())
ll x[200005], y[200005], ind[200005], par[200005], sz[200005], suf[200005];
bool comp(ll i, ll j) { return x[i] < x[j]; }
ll find(ll i) {
  if (par[i] == i)
    return i;
  return par[i] = find(par[i]);
}
void merge(ll x, ll y) {
  x = find(x), y = find(y);
  if (x == y)
    return;
  if (sz[x] < sz[y])
    swap(x, y);
  par[y] = x;
  sz[x] += sz[y];
}
void solve() {
  ll n;
  cin >> n;
  for (ll i = 1; i <= n; i++) {
    cin >> x[i] >> y[i];
    ind[i] = i;
    par[i] = i;
    sz[i] = 1;
  }
  sort(ind + 1, ind + n + 1, comp);
  for (ll qc = n; qc >= 1; qc--) {
    ll i = ind[qc];
    suf[qc] = max(y[i], suf[qc + 1]);
  }
  for (ll i = 1; i <= n; i++) {
    ll j = i, lo = y[ind[i]];
    while (j <= n && lo <= suf[j]) {
      lo = min(lo, y[ind[j]]);
      merge(ind[i], ind[j]);
      j++;
    }
    i = j - 1;
  }
  for (ll i = 1; i <= n; i++)
    cout << sz[find(i)] << "\\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  clock_t z = clock();
  ll qc = 1;
  // cin>>qc;
  for (ll i = 1; i <= qc; i++) {
    solve();
  }
  debug("Total Time:%.4Lf\\n", (ld)(clock() - z) / CLOCKS_PER_SEC);
}