#include <bits/stdc++.h>
using namespace std;
const int MAX = 200010;
int n, sum[MAX], ans[MAX];
struct node {
  int l, r, id;
};
node qu[MAX];
bool cmp1(node n1, node n2) {
  if (n1.r == n2.r) {
    return n1.l < n2.l;
  }
  return n1.r < n2.r;
}
bool cmp2(node n1, node n2) {
  if (n1.l == n2.l) {
    return n1.r < n2.r;
  }
  return n1.l > n2.l;
}
int lowbit(int x) { return x & (-x); }
void update(int x) {
  while (x <= n) {
    sum[x]++;
    x += lowbit(x);
  }
}
int query(int x) {
  int s = 0;
  while (x > 0) {
    s += sum[x];
    x -= lowbit(x);
  }
  return s;
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> qu[i].l >> qu[i].r;
    qu[i].id = i;
  }
  sort(qu + 1, qu + n + 1, cmp1);
  for (int i = 1; i <= n; i++) {
    qu[i].r = i;
  }
  sort(qu + 1, qu + n + 1, cmp2);
  for (int i = 1; i <= n; i++) {
    ans[qu[i].id] = query(qu[i].r);
    update(qu[i].r);
  }
  for (int i = 1; i <= n; i++) {
    cout << ans[i] << '\n';
  }
  return 0;
}
