#include <bits/stdc++.h>
using namespace std;
int n;
pair<pair<int, int>, int> p[200005];
int t[200005], ans[2000005], a[200005];
void san() {
  for (int i = 1; i <= n; ++i) t[i] = p[i].first.first;
  sort(t + 1, t + 1 + n);
  for (int i = 1; i <= n; ++i)
    p[i].first.first = lower_bound(t + 1, t + 1 + n, p[i].first.first) - t;
}
bool cmp(pair<pair<int, int>, int> a, pair<pair<int, int>, int> b) {
  return a.first.second < b.first.second;
}
void add(int x) {
  while (x <= n) {
    a[x]++;
    x += x & (-x);
  }
}
int getSum(int x) {
  int res = 0;
  while (x >= 1) {
    res += a[x];
    x -= x & (-x);
  }
  return res;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d%d", &p[i].first.first, &p[i].first.second);
    p[i].second = i;
  }
  san();
  sort(p + 1, p + 1 + n, cmp);
  for (int i = 1; i <= n; ++i) {
    ans[p[i].second] = i - 1 - getSum(p[i].first.first);
    add(p[i].first.first);
  }
  for (int i = 1; i <= n; ++i) printf("%d\n", ans[i]);
  return 0;
}
