#include <bits/stdc++.h>
using namespace std;
const int N = 2 * 100010;
struct Seg {
  int l, r;
  int idx;
  int sum;
} tmp[N], in[N];
int n;
int c[N];
int ans[N];
void init() {
  memset(c, 0, sizeof(c));
  memset(tmp, 0, sizeof(tmp));
  memset(in, 0, sizeof(in));
  memset(ans, 0, sizeof(ans));
}
bool cmp2(Seg a, Seg b) { return a.r < b.r; }
bool cmp(Seg a, Seg b) { return a.l > b.l; }
int lowbit(int x) { return x & (-x); }
void update(int x, int va) {
  while (x <= n) {
    c[x] += va;
    x += lowbit(x);
  }
}
int query(int x) {
  int sum = 0;
  while (x > 0) {
    sum += c[x];
    x -= lowbit(x);
  }
  return sum;
}
void test() {
  for (int i = 0; i < n; i++) {
    printf("idx: %d l: %d r: %d\n", in[i].idx, in[i].l, in[i].r);
  }
}
int main() {
  while (cin >> n) {
    init();
    int a, b;
    for (int i = 0; i < n; i++) {
      scanf("%d %d", &a, &b);
      tmp[i].l = a;
      tmp[i].r = b;
      tmp[i].idx = i;
    }
    sort(tmp, tmp + n, cmp2);
    for (int i = 0; i < n; i++) {
      int idx = tmp[i].idx;
      in[idx].l = tmp[i].l;
      in[idx].r = i + 1;
      in[idx].idx = idx;
    }
    sort(in, in + n, cmp);
    for (int i = 0; i < n; i++) {
      int idx = in[i].idx;
      ans[idx] = query(in[i].r);
      update(in[i].r, 1);
    }
    for (int i = 0; i < n; i++) {
      printf("%d\n", ans[i]);
    }
  }
  return 0;
}
