#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 7;
int BIT[N];
int ans[N];
int left1[N];
int right1[N];
int id[N];
int n;
bool compare(int i, int j) { return right1[i] < right1[j]; }
bool compare2(int i, int j) { return left1[i] > left1[j]; }
inline void update(long long int x) {
  for (; x <= n; x += x & -x) {
    BIT[x]++;
  }
  return;
}
inline int query(int x) {
  int ans = 0;
  for (; x; x -= x & -x) {
    ans += BIT[x];
  }
  return ans;
}
int main(void) {
  cin >> n;
  for (long long int j = 0; j < n; j++) {
    cin >> left1[j] >> right1[j];
    id[j] = j;
  }
  sort(id, id + n, compare);
  for (long long int i = 0; i < n; i++) {
    right1[id[i]] = i + 1;
  }
  sort(id, id + n, compare2);
  for (long long int j = 0; j < n; j++) {
    ans[id[j]] = query(right1[id[j]]);
    update(right1[id[j]]);
  }
  for (long long int j = 0; j < n; j++) {
    cout << ans[j] << endl;
  }
  return 0;
}
