#include <bits/stdc++.h>
using namespace std;
int n, x[1000000], y[1000000];
map<int, int> mp, rmp;
int b[1000000];
int sz;
int ans[1000000];
int f[1000000];
void up(int x) {
  for (; x <= sz; x |= (x + 1)) ++f[x];
}
int get(int x) {
  int res = 0;
  for (; x >= 0; x &= (x + 1), --x) res += f[x];
  return res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> x[i] >> y[i];
    mp[x[i]] = 1;
    mp[y[i]] = 1;
  }
  for (map<int, int>::iterator it = mp.begin(); it != mp.end(); it++)
    rmp[it->first] = ++sz;
  for (int i = 1; i <= n; i++) x[i] = rmp[x[i]], y[i] = rmp[y[i]];
  for (int i = 1; i <= n; i++) b[y[i]] = x[i];
  for (int i = 1; i <= sz; i++) {
    if (b[i] == 0) continue;
    ans[i] = get(i) - get(b[i]);
    up(b[i]);
  }
  for (int i = 1; i <= n; i++) cout << ans[y[i]] << "\n";
}
