#include <bits/stdc++.h>
using namespace std;
const int MAX = 2e5 + 5;
vector<pair<pair<int, int>, int> > vec;
vector<int> temp;
int s[MAX * 8], a[MAX], b[MAX], qq[MAX];
map<int, int> mp;
void update(int idx, int l, int r, int tar) {
  if (l == r) {
    s[idx] = 1;
    return;
  }
  int mid = (l + r) >> 1;
  if (tar <= mid)
    update(idx * 2, l, mid, tar);
  else
    update(idx * 2 + 1, mid + 1, r, tar);
  s[idx] = s[idx * 2] + s[idx * 2 + 1];
}
int query(int idx, int l, int r, int tL, int tR) {
  if (l > tR || r < tL) return 0;
  if (l >= tL && r <= tR) return s[idx];
  int mid = (l + r) >> 1;
  return query(idx * 2, l, mid, tL, tR) +
         query(idx * 2 + 1, mid + 1, r, tL, tR);
}
int main() {
  int n, x, y;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d%d", &a[i], &b[i]);
    temp.push_back(a[i]);
    temp.push_back(b[i]);
  }
  sort(temp.begin(), temp.end());
  int cnt = 1;
  for (auto t : temp) mp[t] = cnt++;
  for (int i = 0; i < n; i++) vec.push_back({{mp[a[i]], mp[b[i]]}, i});
  sort(vec.rbegin(), vec.rend());
  for (int i = 0; i < vec.size(); i++) {
    qq[vec[i].second] =
        query(1, 1, n * 2, vec[i].first.first, vec[i].first.second);
    update(1, 1, n * 2, vec[i].first.second);
  }
  for (int i = 0; i < n; i++) printf("%d\n", qq[i]);
  return 0;
}
