#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
const int N = 4e5 + 10;
map<int, int> mp;
int fenw[N];
void add(int idx) {
  for (; idx < N; idx = idx | (idx + 1)) {
    fenw[idx]++;
  }
}
int get(int r) {
  int res = 0;
  for (; r >= 0; r = (r & (r + 1)) - 1) res += fenw[r];
  return res;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> l(n), r(n);
  vector<vector<int> > vv(n, vector<int>(3, 0));
  vector<int> t;
  for (int i = 0; i < n; i++) {
    cin >> l[i] >> r[i];
    t.push_back(l[i]);
    t.push_back(r[i]);
  }
  int cur = 1;
  sort(t.begin(), t.end());
  for (int it : t) {
    if (!mp[it]) {
      mp[it] = cur++;
    }
  }
  for (int i = 0; i < n; i++) {
    vv[i][0] = mp[l[i]];
    vv[i][1] = mp[r[i]];
    vv[i][2] = i;
  }
  sort(vv.begin(), vv.end(), [&](vector<int> p1, vector<int> p2) -> bool {
    if (p1[0] == p2[0]) return p1[1] < p2[1];
    return p1[0] > p2[0];
  });
  vector<int> ans(n);
  for (int i = 0; i < n; i++) {
    ans[vv[i][2]] = get(vv[i][1]);
    add(vv[i][1]);
  }
  for (int it : ans) {
    cout << it << endl;
  }
  return 0;
}
