#include <bits/stdc++.h>
using namespace std;
struct node {
  int l, r, pos;
} a[1200000];
int num[1200000];
int tree[1004005];
int ans[1000500];
int cmp(node a, node b) {
  if (a.l != b.l)
    return a.l < b.l;
  else
    return a.r < b.r;
}
int lowbit(int x) { return x & (-x); }
int sum(int x) {
  int sum = 0;
  while (x > 0) {
    sum += tree[x];
    x -= lowbit(x);
  }
  return sum;
}
void add(int x, int c) {
  while (x <= 1000000) {
    tree[x] += c;
    x += lowbit(x);
  }
}
int main() {
  int n;
  while (~scanf("%d", &n)) {
    int cnt = 0;
    memset(tree, 0, sizeof(tree));
    for (int i = 0; i < n; i++) {
      scanf("%d%d", &a[i].l, &a[i].r);
      a[i].pos = i;
      num[cnt++] = a[i].l;
      num[cnt++] = a[i].r;
    }
    map<int, int> s;
    int contz = 1;
    sort(num, num + cnt);
    sort(a, a + n, cmp);
    for (int i = 0; i < cnt; i++) {
      if (s[num[i]] == 0) {
        s[num[i]] = contz;
        contz++;
      }
    }
    for (int i = 0; i < n; i++) add(s[a[i].r], 1);
    for (int i = 0; i < n; i++) {
      add(s[a[i].r], -1);
      ans[a[i].pos] = sum(s[a[i].r] - 1);
    }
    for (int i = 0; i < n; i++) printf("%d\n", ans[i]);
  }
}
