#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
bool mod(long double a, long double b) { return a / b - floor(a / b); }
struct bit {
  long long n;
  vector<long long> B;
  void began(long long a) {
    n = a + 1;
    long long i;
    for (i = 0; i < n + 5; i++) {
      B.push_back(0);
    }
  }
  void update(long long p, long long val) {
    while (p <= n) {
      B[p] += val;
      p += p & (-p);
    }
  }
  long long sum(long long p) {
    long long s = 0;
    if (p == 0) return 0;
    while (p > 0) {
      s += B[p];
      p -= p & (-p);
    }
    return s;
  }
};
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long i, j, n, m, sum, first;
  cin >> n;
  vector<pair<long long, long long>> v;
  vector<pair<pair<long long, long long>, long long>> seg;
  long long a, b;
  for (i = 0; i < n; i++) {
    cin >> a >> b;
    v.push_back({a, 0});
    v.push_back({b, 1});
    seg.push_back({{a, b}, i});
  }
  map<long long, long long> mp;
  m = 1;
  sort((v).begin(), (v).end());
  for (i = 0; i < v.size(); i++) {
    if (mp[v[i].first] == 0) {
      mp[v[i].first] = m;
      m++;
    }
  }
  bit tree;
  tree.began(10);
  tree.update(8, 1);
  long long start[m], stop[m];
  bit btree;
  btree.began(m);
  for (i = 0; i < n; i++) {
    btree.update(mp[seg[i].first.second], 1);
  }
  sort((seg).begin(), (seg).end());
  long long ans[n];
  for (i = 0; i < n; i++) {
    pair<long long, long long> p = seg[i].first;
    btree.update(mp[p.second], -1);
    first = btree.sum(mp[p.second]) - btree.sum(mp[p.first] - 1);
    ans[seg[i].second] = first;
  }
  for (i = 0; i < n; i++) {
    cout << ans[i] << '\n';
  }
  return 0;
}
