#include <bits/stdc++.h>
using namespace std;
template <typename _Tp, typename _Up>
bool maximize(_Tp &__a, _Up __b) {
  if (__a < __b) {
    __a = __b;
    return true;
  }
  return false;
}
template <typename _Tp, typename _Up>
bool minimize(_Tp &__a, _Up __b) {
  if (__a > __b) {
    __a = __b;
    return true;
  }
  return false;
}
const long long siz = 2e5 + 2;
const long long SIZ = 1e6 + 2;
const long long mod = 1e9 + 7;
const long long maxx = 2e9;
const long long MAXX = 1e18;
const string file = "3";
struct fenwick_tree {
  long long n;
  vector<long long> fwt;
  fenwick_tree(long long n) : n(n) { fwt.assign(n + 1, 0); }
  void pos_update(long long pos, long long val) {
    assert(1 <= pos && pos <= n);
    for (long long i = pos; i <= n; i += i & (-i)) {
      fwt[i] += val;
    }
  }
  long long pre_sum(long long pos) {
    assert(0 <= pos && pos <= n + 1);
    long long res = 0;
    for (long long i = pos; i > 0; i -= i & (-i)) {
      res += fwt[i];
    }
    return res;
  }
  long long suf_sum(long long pos) { return (pre_sum(n) - pre_sum(pos - 1)); }
  long long range_sum(long long lt, long long rt) {
    if (lt > rt) {
      return 0;
    }
    return (pre_sum(rt) - pre_sum(lt - 1));
  }
};
long long ans[siz];
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> n;
  vector<pair<pair<long long, long long>, long long> > hold;
  for (long long i = 1; i <= n; i++) {
    long long l, r;
    cin >> l >> r;
    hold.push_back(pair<pair<long long, long long>, long long>(
        pair<long long, long long>(l, r), i));
  }
  vector<long long> rar;
  for (auto x : hold) {
    rar.push_back(x.first.first);
    rar.push_back(x.first.second);
  }
  sort((rar).begin(), (rar).end());
  rar.resize(unique((rar).begin(), (rar).end()) - rar.begin());
  for (auto &x : hold) {
    long long &l = x.first.first, &r = x.first.second;
    l = lower_bound((rar).begin(), (rar).end(), l) - rar.begin() + 1;
    r = lower_bound((rar).begin(), (rar).end(), r) - rar.begin() + 1;
  }
  sort((hold).begin(), (hold).end(),
       [](const pair<pair<long long, long long>, long long> &x,
          const pair<pair<long long, long long>, long long> &y) {
         return (x.first.first > y.first.first);
       });
  fenwick_tree fen(2 * n);
  for (auto x : hold) {
    long long l = x.first.first, r = x.first.second, i = x.second;
    ans[i] = fen.pre_sum(r);
    fen.pos_update(r, 1);
  }
  for (long long i = 1; i <= n; i++) {
    cout << ans[i] << "\n";
  }
  return 0;
}
