#include <bits/stdc++.h>
using namespace std;
template <typename T>
struct SegmentTree {
 private:
  int n;
  vector<T> tree;
  function<T(const T &, const T &)> op;
  T id;

 public:
  SegmentTree(function<T(const T &, const T &)> binaryOperation,
              const T identityValue)
      : op(binaryOperation), id(identityValue) {}
  void build() {
    for (int i = n - 1; i > 0; --i) {
      tree[i] = op(tree[i << 1], tree[i << 1 | 1]);
    }
  }
  void build(const int size, const T &val) {
    n = size;
    tree.resize(2 * n, id);
    for (int i = 0; i < n; ++i) {
      tree[n + i] = val;
    }
    build();
  }
  void update(int pos, T delta) {
    tree[n + pos] += delta;
    for (int i = pos + n; i > 1; i >>= 1) {
      tree[i >> 1] = op(tree[i], tree[i ^ 1]);
    }
  }
  T query(int l, int r) {
    T result = id;
    l += n;
    r += n;
    for (; l < r; l >>= 1, r >>= 1) {
      if (l & 1) result = op(result, tree[l++]);
      if (r & 1) result = op(result, tree[--r]);
    }
    return result;
  }
};
struct Seg {
  int l;
  int r;
  int i;
};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int N;
  cin >> N;
  vector<Seg> v(N);
  for (int n = 0; n < N; ++n) {
    cin >> v[n].l;
    cin >> v[n].r;
    v[n].i = n;
  }
  auto compL = [](const Seg &lhs, const Seg &rhs) { return lhs.l > rhs.l; };
  auto compR = [](const Seg &lhs, const Seg &rhs) { return lhs.r < rhs.r; };
  sort(v.begin(), v.end(), compR);
  for (int n = 0; n < N; ++n) {
    v[n].r = n;
  }
  sort(v.begin(), v.end(), compL);
  auto op = [](const int &lhs, const int &rhs) { return lhs + rhs; };
  SegmentTree<int> st(op, 0);
  st.build(N, 0);
  vector<int> result(N);
  for (int n = 0; n < N; ++n) {
    result[v[n].i] = st.query(0, v[n].r);
    st.update(v[n].r, 1);
  }
  for (int n = 0; n < N; ++n) {
    cout << result[n] << '\n';
  }
  return 0;
}
