#include <bits/stdc++.h>
using namespace std;
long long a[5000005], b[5000005], c[5000005], r, m, n, sum = 0;
vector<long long> v;
pair<long long, long long> p[5000005];
map<pair<long long, long long>, long long> pos;
long long fin(long long t) {
  m = 0;
  while (t) {
    m = m + a[t];
    t -= t & (-t);
  }
  return m;
}
void upd(long long t) {
  long long i = t;
  while (i <= n) {
    a[i]++;
    i += (i & (-i));
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  long long k = 0, t = 0, x, y = 0, l = 1, i, j;
  cin >> n;
  for (i = 0; i < n; i++)
    cin >> p[i].first >> p[i].second, pos[p[i]] = i, v.push_back(p[i].second);
  sort(v.begin(), v.end());
  sort(p, p + n);
  for (i = 0; i < n; i++) {
    t = lower_bound(v.begin(), v.end(), p[i].second) - v.begin();
    l = t - fin(t + 1);
    upd(t + 1);
    b[pos[p[i]]] = l;
  }
  for (i = 0; i < n; i++) cout << b[i] << endl;
  return 0;
}
