#include <bits/stdc++.h>
using namespace std;
const int module = 1e9 + 7;
class fenwick_tree {
 public:
  int get_sum(int i) {
    int res = 0;
    for (; i >= 0; i = (i & (i + 1)) - 1) res += s[i];
    return res;
  }
  int get_sum(int left, int right) {
    if (right < left) return 0;
    return get_sum(right) - get_sum(left - 1);
  }
  void increase(int i, int v) {
    a[i] += v;
    for (; i < s.size(); i = (i | (i + 1))) s[i] += v;
  }
  fenwick_tree(int n) {
    a.assign(n, 0);
    s.assign(n, 0);
  }

 private:
  vector<int> a;
  vector<int> s;
};
struct segment {
  int l, r, id;
};
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  vector<segment> p(n);
  vector<int> q(n);
  for (int i = 0; i < n; ++i) {
    cin >> p[i].l >> p[i].r;
    p[i].id = i;
    q[i] = p[i].r;
  }
  sort(p.begin(), p.end(), [](segment a, segment b) { return a.l > b.l; });
  sort(q.begin(), q.end());
  map<int, int> index;
  for (int i = 0; i < n; ++i) index[q[i]] = i;
  fenwick_tree f(n);
  vector<int> ans(n);
  for (int i = 0; i < n; ++i) {
    int ind = index[p[i].r];
    ans[p[i].id] = f.get_sum(ind);
    f.increase(ind, 1);
  }
  for (int i = 0; i < n; ++i) cout << ans[i] << "\n";
  return 0;
}
