#include <bits/stdc++.h>
#pragma warning(disable : 4996)
using namespace std;
int n;
pair<pair<int, int>, int> a[300000];
int it[1100000];
int S;
int ans[300000];
void update(int x) {
  for (x /= 2; x > 0; x /= 2) it[x] = it[x * 2] + it[x * 2 + 1];
}
int getsum(int x, int y) {
  int sum = 0;
  while (x <= y) {
    if (x % 2 == 1) sum += it[x++];
    if (y % 2 == 0) sum += it[y--];
    x /= 2, y /= 2;
  }
  return sum;
}
int main() {
  int i, j, k, l;
  cin >> n;
  map<int, int> mq;
  for (i = 0; i < n; i++)
    scanf("%d%d", &a[i].first.first, &a[i].first.second),
        a[i].second = i, mq[a[i].first.first] = mq[a[i].first.second] = 0;
  int m = 0;
  for (auto &e : mq) {
    e.second = m++;
  }
  for (i = 0; i < n; i++)
    a[i].first.first = mq[a[i].first.first],
    a[i].first.second = mq[a[i].first.second];
  sort(a, a + n, greater<pair<pair<int, int>, int>>());
  for (S = 1; S < m; S *= 2)
    ;
  for (i = 0; i < n; i++) {
    ans[a[i].second] = getsum(S + a[i].first.first, S + a[i].first.second);
    it[S + a[i].first.second]++;
    update(S + a[i].first.second);
  }
  for (i = 0; i < n; i++) printf("%d\n", ans[i]);
  return 0;
}
