#include <bits/stdc++.h>
using namespace std;
int L[400005], R[400005];
int sto[400005];
struct itv {
  int L, R, id;
  bool operator<(const itv &p) const { return R != p.R ? R < p.R : L > p.L; }
} p[400005];
int m;
int bit[400005];
void add(int p) {
  for (int i = p; i <= m; i += i & -i) bit[i]++;
}
int calc(int p) {
  int rlt = 0;
  for (int i = p; i; i -= i & -i) rlt += bit[i];
  return rlt;
}
int rlt[400005];
int main() {
  int n;
  scanf("%d", &n);
  m = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%d %d", L + i, R + i);
    sto[++m] = L[i];
    sto[++m] = R[i];
  }
  sort(sto + 1, sto + m + 1);
  m = unique(sto + 1, sto + m + 1) - sto - 1;
  for (int i = 1; i <= n; i++) {
    p[i].id = i;
    p[i].L = lower_bound(sto + 1, sto + m + 1, L[i]) - sto;
    p[i].R = lower_bound(sto + 1, sto + m + 1, R[i]) - sto;
  }
  sort(p + 1, p + n + 1);
  for (int i = 1; i <= n; i++) {
    rlt[p[i].id] = i - calc(p[i].L - 1) - 1;
    add(p[i].L);
  }
  for (int i = 1; i <= n; i++) printf("%d\n", rlt[i]);
}
