#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:102400000,102400000")
using namespace std;
template <class T, class U>
inline void Max(T &a, U b) {
  if (a < b) a = b;
}
template <class T, class U>
inline void Min(T &a, U b) {
  if (a > b) a = b;
}
inline void add(int &a, int b) {
  a += b;
  while (a >= 1000000007) a -= 1000000007;
}
int pow(int a, int b) {
  int ans = 1;
  while (b) {
    if (b & 1) ans = ans * (long long)a % 1000000007;
    a = (long long)a * a % 1000000007;
    b >>= 1;
  }
  return ans;
}
pair<int, pair<int, int> > b[200010];
int v[200010], f[200010], ans[200010];
int query(int first) {
  int ans = 0;
  while (first < 200010) ans += f[first], first += first & -first;
  return ans;
}
void upd(int first) {
  while (first > 0) f[first]++, first -= first & -first;
}
int main() {
  int i, j, k, n, m = 0;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d%d", &j, &k);
    v[m++] = j;
    b[i].first = k;
    b[i].second = make_pair(j, i);
  }
  sort(v, v + m);
  m = unique(v, v + m) - v;
  sort(b, b + n);
  for (i = 0; i < n; i++) {
    k = lower_bound(v, v + m, b[i].second.first) - v + 1;
    ans[b[i].second.second] = query(k);
    upd(k);
  }
  for (i = 0; i < n; i++) printf("%d\n", ans[i]);
  return 0;
}
