#include <bits/stdc++.h>
using namespace std;
int chh;
const int N = 200005;
int n, e;
int a[N << 1], ans[N], b[N << 1];
pair<pair<int, int>, int> p[N];
void init() { memset(b, 0, sizeof(b)); }
void add(int x, int y) {
  for (; x > 0; x -= ((x) & (-x))) b[x] += y;
}
int cal(int x) {
  int ans = 0;
  for (; x <= e; x += ((x) & (-x))) ans += b[x];
  return ans;
}
bool cmp(const pair<pair<int, int>, int> &arg0,
         const pair<pair<int, int>, int> &arg1) {
  return arg0.first.second < arg1.first.second;
}
int main() {
  while (~scanf("%d", &n)) {
    e = 0;
    for (int i = 0; i < (n); i++) {
      scanf("%d %d", &p[i].first.first, &p[i].first.second);
      a[e++] = p[i].first.first, a[e++] = p[i].first.second;
      p[i].second = i;
    }
    sort(a, a + e);
    e = unique(a, a + e) - a;
    for (int i = 0; i < (n); i++) {
      p[i].first.first = lower_bound(a, a + e, p[i].first.first) - a + 1;
      p[i].first.second = lower_bound(a, a + e, p[i].first.second) - a + 1;
    }
    sort(p, p + n, cmp);
    init();
    for (int i = 0; i < (n); i++) {
      ans[p[i].second] = cal(p[i].first.first + 1);
      add(p[i].first.first, 1);
    }
    for (int i = 0; i < (n); i++) printf("%d\n", ans[i]);
  }
  return 0;
}
