#include <bits/stdc++.h>
using namespace std;
struct BIT {
  static const int size = 400000;
  int d[400010];
  int lowbit(int x) { return x & (-x); }
  void modify(int pos, int val) {
    while (pos <= size) d[pos] += val, pos += lowbit(pos);
  }
  int query(int pos) {
    int ret = 0;
    while (pos) ret += d[pos], pos -= lowbit(pos);
    return ret;
  }
} T;
struct data {
  int val, id;
  bool operator<(const data &n1) const { return val < n1.val; }
} d[400010];
struct Line {
  int l, r, id;
  bool operator<(const Line &n1) const {
    return l == n1.l ? r < n1.r : l > n1.l;
  }
} L[200010];
int n, maxnum;
int ans[2000010];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &d[i].val);
    d[i].id = i;
    scanf("%d", &d[i + n].val);
    d[i + n].id = i + n;
  }
  sort(d + 1, d + 2 * n + 1);
  maxnum = 0;
  for (int i = 1; i <= n * 2; i++) {
    if (d[i].val != d[i - 1].val) maxnum++;
    if (d[i].id > n)
      L[d[i].id - n].r = maxnum;
    else
      L[d[i].id].l = maxnum;
  }
  for (int i = 1; i <= n; i++) L[i].id = i;
  sort(L + 1, L + n + 1);
  for (int i = 1; i <= n; i++) {
    ans[L[i].id] = T.query(L[i].r);
    T.modify(L[i].r + 1, 1);
  }
  for (int i = 1; i <= n; i++) printf("%d\n", ans[i]);
  return 0;
}
