#include <bits/stdc++.h>
const long long inf = 0x3f3f3f3f3f3f3f3LL;
const long long mod = (long long)1e9 + 7;
using namespace std;
template <class T>
void smin(T& a, T val) {
  if (a > val) a = val;
}
template <class T>
void smax(T& a, T val) {
  if (a < val) a = val;
}
const long long N = 1e6 + 10;
long long n;
vector<pair<pair<long long, long long>, long long>> a;
map<long long, long long> M;
vector<long long> compress(vector<long long> a) {
  vector<long long> b = a;
  sort(b.begin(), b.end());
  b.erase(unique(b.begin(), b.end()), b.end());
  for (long long& x : a) {
    long long tmp =
        (long long)(lower_bound(b.begin(), b.end(), x) - b.begin()) + 1;
    M[x] = tmp;
    x = tmp;
  }
  return a;
}
long long ft[N];
long long query(long long b) {
  long long sum = 0;
  if (b <= 0) return 0;
  for (; b; b -= (b & (-b))) sum += ft[b];
  return sum;
}
void update(long long k, long long v) {
  for (; k <= N; k += (k & (-k))) ft[k] += v;
}
void range_update(long long i, long long j, long long v) {
  ;
  update(i, v);
  update(j + 1, -v);
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n;
  a.resize(n);
  vector<long long> vals;
  for (long long i = 0; i < n; ++i) {
    cin >> a[i].first.second >> a[i].first.first;
    a[i].second = i;
    vals.push_back(a[i].first.second);
    vals.push_back(a[i].first.first);
  }
  compress(vals);
  for (auto& it : a) {
    it.first.second = M[it.first.second];
    it.first.first = M[it.first.first];
  };
  sort(a.begin(), a.end());
  vector<long long> ans(n);
  for (long long i = 0; i < n; ++i) {
    long long r = a[i].first.first, l = a[i].first.second;
    long long idx = a[i].second;
    ans[idx] = query(r) - query(l - 1);
    range_update(l, N, 1);
  }
  for (auto i : ans) cout << i << '\n';
  return 0;
}
