#include <bits/stdc++.h>
using namespace std;
struct fenwick_tree {
  int n;
  vector<int> fen;
  void build(int size) {
    n = size;
    fen.assign(n, 0);
  }
  fenwick_tree(int n) { build(n); }
  int get(int u) {
    int s = 0;
    while (u >= 1) {
      s += fen[u];
      u -= u & -u;
    }
    return s;
  }
  void upd(int u, int x) {
    while (u <= n) {
      fen[u] += x;
      u += u & -u;
    }
  }
  int get(int l, int r) {
    int x = get(r);
    if (l > 0) x -= get(l - 1);
    return x;
  }
};
void solve() {
  int n;
  cin >> n;
  fenwick_tree fen1(1e6);
  fenwick_tree fen2(1e6);
  map<int, int> m;
  set<int> s;
  vector<pair<pair<int, int>, int>> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i].first.first >> a[i].first.second;
    s.insert(a[i].first.first);
    s.insert(a[i].first.second);
    a[i].second = i;
  }
  int compress = 1;
  for (auto x : s) {
    m[x] = compress++;
  }
  for (int i = 0; i < n; i++) {
    a[i].first.first = m[a[i].first.first],
    a[i].first.second = -m[a[i].first.second];
  }
  sort(a.begin(), a.end());
  int ans1[n], ans2[n];
  for (int i = 0; i < n; i++) {
    int now = -a[i].first.second;
    ans2[a[i].second] = fen1.get(now, 1e6);
    fen1.upd(now, 1);
  }
  sort(a.rbegin(), a.rend());
  for (int i = 0; i < n; i++) {
    int now = -a[i].first.second;
    ans1[a[i].second] = fen2.get(now);
    fen2.upd(now, 1);
  }
  for (int i = 0; i < n; i++) cout << ans1[i] << '\n';
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  int t = 1;
  while (t--) {
    solve();
  }
}
