#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;

struct UnionFindTree {
  std::vector<int> data;

  UnionFindTree(int size) : data(size, -1) { }
  bool Unite(int x, int y) {
    x = Root(x); y = Root(y);
    if (x != y) {
      if (data[y] < data[x]) std::swap(x, y);
      data[x] += data[y];
      data[y] = x;
    }
    return x != y;
  }
  bool IsSameRoot(int x, int y) {
    return Root(x) == Root(y);
  }
  int Root(int x) {
    return data[x] < 0 ? x : data[x] = Root(data[x]);
  }
  int Size(int x) { return -data[Root(x)]; }
};

int main() {
  int N; cin >> N;
  vector<P> ps(N);
  vector<TP> tps(N);
  for (int i = 0; i < N; ++i) {
    int x, y; cin >> x >> y;
    ps[i] = {x, y};
    tps[i] = {x, y, i};
  }

  UnionFindTree tree(N);
  sort(tps.begin(), tps.end());
  map<int, int> m;
  for (int i = 0; i < N; ++i) {
    bool first = true;
    auto [x, y, k] = tps[i];
    for (auto [y2, k2] : m) {
      if (y < y2) break;
      first = false;
      tree.Unite(k, k2);
//      cout << y << " " << y2 << "->" << i << " and " << i2 << " is same" << endl;
    }
    if (first) m[y] = k;
  }

  for (int i = 0; i < N; ++i) cout << tree.Size(i) << endl;
}
