#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int c[N], rr[N], ans[N];
struct node {
  int l, r;
  int id;
  bool operator<(const node& a) const { return l == a.l ? r < a.r : l > a.l; }
} seg[N];
void add(int i) {
  while (i < N) c[i]++, i += (i) & (-i);
}
int sum(int i) {
  int ans = 0;
  while (i) ans += c[i], i -= (i) & (-i);
  return ans;
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d %d", &seg[i].l, &seg[i].r);
    rr[i] = seg[i].r;
    seg[i].id = i;
  }
  sort(rr + 1, rr + 1 + n);
  int k = unique(rr + 1, rr + 1 + n) - rr;
  for (int i = 1; i <= n; i++)
    seg[i].r = lower_bound(rr + 1, rr + k, seg[i].r) - rr;
  sort(seg + 1, seg + 1 + n);
  for (int i = 1; i <= n; i++) {
    ans[seg[i].id] = sum(seg[i].r);
    add(seg[i].r + 1);
  }
  for (int i = 1; i <= n; i++) printf("%d\n", ans[i]);
  return 0;
}
