#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > A, B;
vector<int> R, T;
map<pair<int, int>, int> ID, P;
int f(int first, int second) { return (first + second); }
void build(int ver, int p, int q) {
  int med = (p + q) / 2, left = 2 * ver + 1, rigth = 2 * ver + 2;
  if (p == q) {
    T[ver] = 1;
    return;
  }
  build(left, p, med);
  build(rigth, med + 1, q);
  T[ver] = f(T[left], T[rigth]);
}
void update(int ver, int p, int q, int valor, int i) {
  int med = (p + q) / 2, left = 2 * ver + 1, rigth = 2 * ver + 2;
  if (p == q && p == i) {
    T[ver] = valor;
    return;
  }
  if (i <= med)
    update(left, p, med, valor, i);
  else
    update(rigth, med + 1, q, valor, i);
  T[ver] = f(T[left], T[rigth]);
}
int query(int ver, int p, int q, int l, int r) {
  int med = (p + q) / 2, left = 2 * ver + 1, rigth = 2 * ver + 2;
  if (l == p && r == q) return T[ver];
  if (r <= med) return query(left, p, med, l, r);
  if (l > med) return query(rigth, med + 1, q, l, r);
  return f(query(left, p, med, l, med), query(rigth, med + 1, q, med + 1, r));
}
int main() {
  int n;
  while (cin >> n) {
    T.resize(3 * n);
    build(0, 0, n - 1);
    A.resize(n);
    B.resize(n);
    R.resize(n);
    ID.clear();
    P.clear();
    int first, second;
    for (int i = 0; i < n; i++) {
      cin >> first >> second;
      A[i] = pair<int, int>(second, first);
      B[i] = pair<int, int>(first, second);
      ID[pair<int, int>(first, second)] = i;
    }
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    for (int i = 0; i < n; i++) P[B[i]] = i;
    for (int i = 0; i < n; i++) swap(A[i].first, A[i].second);
    for (int i = n - 1; i >= 0; i--) {
      update(0, 0, n - 1, 0, P[A[i]]);
      int a = 0, b = n - 1, c;
      int k = -1, res = 0;
      if ((A[i].first) < (B[0].first)) k = 0;
      if ((A[i].first) >= (B[n - 1].first)) k = n;
      if (k == -1) {
        while (b - a > 1) {
          c = (a + b) / 2;
          if ((A[i].first) >= (B[c].first))
            a = c;
          else
            b = c;
        }
        k = b;
      }
      if (k < n) res += query(0, 0, n - 1, k, n - 1);
      R[ID[A[i]]] = res;
    }
    for (int i = 0; i < n; i++) cout << R[i] << "\n";
  }
  return 0;
}
