#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 3000;
struct BIT {
  int a[maxn];
  void add(int p) {
    while (p < maxn) a[p]++, p += p & -p;
  }
  int sum(int p) {
    int ans = 0;
    while (p > 0) ans += a[p], p -= p & -p;
    return ans;
  }
} B;
int n;
struct Node {
  int l, r, id;
  bool operator<(const Node &C) const { return r < C.r; }
} a[maxn];
int dic[maxn], dh = 0;
int ans[maxn];
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    scanf("%d%d", &a[i].l, &a[i].r);
    a[i].id = i;
    dic[dh++] = a[i].l;
  }
  sort(a, a + n);
  sort(dic, dic + dh);
  dh = unique(dic, dic + dh) - dic;
  for (int i = 0; i < n; i++) {
    int id = a[i].id;
    ans[id] =
        B.sum(1e6) - B.sum((lower_bound(dic, dic + dh, a[i].l) - dic + 1));
    B.add((lower_bound(dic, dic + dh, a[i].l) - dic + 1));
  }
  for (int i = 0; i < n; i++) {
    printf("%d\n", ans[i]);
  }
  return 0;
}
