#include <bits/stdc++.h>
using namespace std;
int lsb(int val) { return val & ((val ^ (val - 1))); }
pair<int, pair<int, int> > a[600666];
int Arb[600666], SEG[600666], result[600666];
bool comp(pair<int, pair<int, int> > i1, pair<int, pair<int, int> > i2) {
  return i1.second.second < i2.second.second;
}
int query(int pos) {
  if (pos) return Arb[pos] + query(pos - lsb(pos));
  return 0;
}
void update(int pos, int n) {
  if (pos > n) return;
  Arb[pos]++;
  update(pos + lsb(pos), n);
}
int bs(int value, int n, int A[]) {
  int left = 1, right = n + 1;
  while (left < right - 1) {
    int mid = (right + left) / 2;
    if (A[mid] <= value)
      left = mid;
    else
      right = mid;
  }
  return left;
}
int main() {
  cin.sync_with_stdio(false);
  int n, i, nr_seg = 0;
  cin >> n;
  for (i = 1; i <= n; ++i) {
    cin >> a[i].second.first >> a[i].second.second;
    a[i].first = i;
    SEG[++nr_seg] = a[i].second.first;
    SEG[++nr_seg] = a[i].second.second;
  }
  sort(SEG + 1, SEG + nr_seg + 1);
  sort(a + 1, a + n + 1, comp);
  for (i = 1; i <= n; ++i) {
    a[i].second.first = bs(a[i].second.first, nr_seg, SEG);
    a[i].second.second = bs(a[i].second.second, nr_seg, SEG);
  }
  for (i = 1; i <= n; ++i) {
    result[a[i].first] = query(a[i].second.second) - query(a[i].second.first);
    update(a[i].second.first, n * 2);
  }
  for (i = 1; i <= n; ++i) cout << result[i] << '\n';
  return 0;
}
