#include <bits/stdc++.h>
using namespace std;
int a[410000];
struct node {
  int l, r, id;
} b[210000];
map<int, int> S;
int n, ans[210000];
int c[410000], num, pos = 1;
int cmp(node a, node b) { return a.l > b.l; }
void add(int x) {
  for (int j = x; j < 410000; j += j & (-j)) a[j]++;
}
int get(int x) {
  int res = 0;
  for (int j = x; j; j -= j & (-j)) res += a[j];
  return res;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++)
    scanf("%d %d", &b[i].l, &b[i].r), c[++num] = b[i].l, c[++num] = b[i].r,
                                      b[i].id = i;
  sort(c + 1, c + 1 + num);
  S[c[1]] = 1;
  for (int i = 2; i <= num; i++)
    if (c[i] != c[i - 1]) S[c[i]] = ++pos;
  for (int i = 1; i <= n; i++) b[i].l = S[b[i].l], b[i].r = S[b[i].r];
  sort(b + 1, b + 1 + n, cmp);
  for (int i = 1; i <= n; i++) {
    ans[b[i].id] = get(b[i].r);
    add(b[i].r);
  }
  for (int i = 1; i <= n; i++) printf("%d\n", ans[i]);
  return 0;
}
