#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:1024000000,1024000000")
using namespace std;
const double PI = acos(-1.0);
const double EPS = 1e-10;
inline int read() {
  static char ch;
  bool sgn = false;
  while (ch = getchar(), ch < '0' || ch > '9')
    if (ch == '-') sgn = true;
  int res = ch - 48;
  while (ch = getchar(), ch >= '0' && ch <= '9') res = res * 10 + ch - 48;
  return sgn ? -res : res;
}
const int N = 2e5 + 5;
struct Q {
  int l, r, id;
  bool operator<(const Q &a) const { return l > a.l; }
} q[N];
int sum[N * 10][2], l[N], r[N], a[N * 2], m;
void Ins(int k, int l, int r, int p, int v) {
  if (l > p || r < p) return;
  if (l == r) {
    sum[k][v]++;
    return;
  }
  int mid = (l + r) >> 1;
  Ins(k << 1, l, mid, p, v);
  Ins((k << 1) + 1, mid + 1, r, p, v);
  sum[k][1] = sum[k << 1][1] + sum[(k << 1) + 1][1];
}
int Query(int k, int l, int r, int p, int q, int v) {
  if (p > r || q < l) return 0;
  if (l >= p && r <= q) return sum[k][v];
  int mid = (l + r) >> 1;
  return Query(k << 1, l, mid, p, q, v) +
         Query((k << 1) + 1, mid + 1, r, p, q, v);
}
int ans[N];
int main() {
  int n = read();
  for (int i = 1; i <= n; i++)
    l[i] = read(), r[i] = read(), a[++m] = l[i], a[++m] = r[i];
  sort(a + 1, a + 1 + m);
  for (int i = 1; i <= n; i++)
    q[i].l = lower_bound(a + 1, a + 1 + m, l[i]) - a,
    q[i].r = lower_bound(a + 1, a + 1 + m, r[i]) - a, q[i].id = i;
  sort(q + 1, q + 1 + n);
  for (int i = 1; i <= n; i++) {
    ans[q[i].id] = Query(1, 1, m, q[i].l, q[i].r, 1);
    Ins(1, 1, m, q[i].r, 1);
  }
  for (int i = 1; i <= n; i++) printf("%d\n", ans[i]);
}
