#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 7;
struct node {
  int l, r, id;
} a[MAXN];
int cnt, d[MAXN], ans[MAXN], t[MAXN];
bool cmp(node b, node c) {
  if (b.l == c.l)
    return b.r < c.r;
  else
    return b.l < c.l;
}
int lowbit(int x) { return x & (-x); }
void add(int x, int val) {
  for (int i = x; i <= cnt; i += lowbit(i)) t[i] += val;
}
int getsum(int x) {
  int sum = 0;
  for (int i = x; i >= 1; i -= lowbit(i)) sum += t[i];
  return sum;
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d%d", &a[i].l, &a[i].r), a[i].id = i;
  sort(a + 1, a + 1 + n, cmp);
  cnt = 0;
  for (int i = 1; i <= n; i++) d[++cnt] = a[i].r;
  sort(d + 1, d + cnt + 1);
  cnt = unique(d + 1, d + 1 + cnt) - d - 1;
  for (int i = n; i >= 1; i--) {
    int pos = lower_bound(d + 1, d + cnt + 1, a[i].r) - d;
    ans[a[i].id] = getsum(pos);
    add(pos, 1);
  }
  for (int i = 1; i <= n; i++) printf("%d\n", ans[i]);
}
