#include <bits/stdc++.h>
using namespace std;
struct FenwickTree {
  vector<int> bit;
  int n;
  FenwickTree(int n) {
    this->n = n;
    bit.assign(n, 0);
  }
  FenwickTree(vector<int> a) : FenwickTree(a.size()) {
    for (size_t i = 0; i < a.size(); i++) add(i, a[i]);
  }
  int sum(int r) {
    int ret = 0;
    for (; r >= 0; r = (r & (r + 1)) - 1) ret += bit[r];
    return ret;
  }
  int sum(int l, int r) { return sum(r) - sum(l - 1); }
  void add(int idx, int delta) {
    for (; idx < n; idx = idx | (idx + 1)) bit[idx] += delta;
  }
};
int main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, l, r, i;
  cin >> n;
  vector<tuple<int, int, int>> s(n);
  vector<int> all;
  for (i = 0; i < n; i++) {
    cin >> l >> r;
    s[i] = make_tuple(l, r, i);
    all.push_back(l);
    all.push_back(r);
  }
  sort(all.begin(), all.end());
  for (i = 0; i < n; i++) {
    get<0>(s[i]) = distance(all.begin(),
                            lower_bound(all.begin(), all.end(), get<0>(s[i])));
    get<1>(s[i]) = distance(all.begin(),
                            lower_bound(all.begin(), all.end(), get<1>(s[i])));
  }
  FenwickTree FT(2 * n);
  vector<int> ans(n);
  sort(s.begin(), s.end(),
       [](const tuple<int, int, int> &a, const tuple<int, int, int> &b) {
         return get<0>(a) < get<0>(b);
       });
  for (i = 0; i < n; i++) FT.add(get<1>(s[i]), 1);
  for (i = 0; i < n; i++) {
    ans[get<2>(s[i])] = FT.sum(get<0>(s[i]), get<1>(s[i]) - 1);
    FT.add(get<1>(s[i]), -1);
  }
  for (i = 0; i < n; i++) cout << ans[i] << "\n";
}
