#include <bits/stdc++.h>
using namespace std;
const int N = 1000000;
pair<int, int> a[N];
vector<pair<int, pair<int, int> > > q;
long long t[N], f[N], ans[N];
int n, i;
int j = 0;
int find(int x) {
  int l = 1, r = n, c;
  while (l < r) {
    c = (l + r) / 2;
    if (x <= f[c])
      r = c;
    else
      l = c + 1;
  }
  while (f[l] > x) l--;
  while (f[l] < x) l++;
  return l;
}
void add(int i, long long x) {
  for (; i <= n; i -= (i | (-i))) t[i] += x;
}
long long get(int i) {
  long long ans = 0;
  for (; i > 0; i -= (i & (-i))) ans += t[i];
  return ans;
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%I64d%I64d", &a[i].first, &a[i].second);
  for (int i = 0; i < n; i++) {
    f[i + 1] = a[i].first;
    q.push_back(make_pair(a[i].first, make_pair((int)-2e9, i)));
    q.push_back(make_pair(a[i].second, make_pair(a[i].first, i)));
  }
  sort(q.begin(), q.end());
  sort(f + 1, f + n + 1);
  for (int i = 0; i < q.size(); i++) {
    if (q[i].second.first == -(int)2e9) {
      continue;
    } else {
      ans[q[i].second.second] = get(find(q[i].second.first));
      add(1, 1);
      add(find(q[i].second.first), -1);
    }
  }
  for (int i = 0; i < n; i++) printf("%I64d\n", ans[i]);
  return 0;
}
