#include <bits/stdc++.h>
using namespace std;
struct segm {
  int x;
  int y;
  int ord;
};
segm v[2000005];
int n, k[2000005], sol[2000005];
int aib[2000005];
int normalizare(int val) {
  int sol = 0;
  for (int i = 1 << 20; i; i >>= 1)
    if (sol + i <= n && k[sol + i] <= val) sol += i;
  return sol;
}
int query(int pos) {
  int sol = 0;
  for (int i = pos; i > 0; i -= i & (-i)) sol += aib[i];
  return sol;
}
void update(int pos) {
  for (int i = pos; i <= n; i += i & (-i)) aib[i]++;
}
bool segmcomp(const segm &a, const segm &b) {
  if (a.x == b.x) return a.y < b.y;
  return a.x < b.x;
}
int main() {
  int i;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    scanf("%d %d", &v[i].x, &v[i].y);
    v[i].ord = i;
  }
  sort(v + 1, v + n + 1, segmcomp);
  for (i = 1; i <= n; i++) k[i] = v[i].y;
  sort(k + 1, k + n + 1);
  for (i = n; i >= 1; i--) {
    v[i].y = normalizare(v[i].y);
    sol[v[i].ord] = query(v[i].y);
    update(v[i].y);
  }
  for (i = 1; i <= n; i++) printf("%d\n", sol[i]);
  return 0;
}
