#include <bits/stdc++.h>
#pragma warning(disable : 4996)
using namespace std;
const int MOD = 1e9 + 7;
const int INF = 1e9;
const int SZ = 400010;
const double PI = 3.1415926535897932384626433832795;
const double EPS = 1e-6;
const int MUL = 239017;
map<int, int> zp;
int l[SZ], r[SZ], d[SZ], ans[SZ];
pair<bool, int> a[SZ];
int get(int x) {
  int sum = 0;
  while (x >= 0) {
    sum += d[x];
    x = (x & (x + 1)) - 1;
  }
  return sum;
}
void upd(int x) {
  while (x < SZ) {
    d[x]++;
    x = (x | (x + 1));
  }
}
int main() {
  srand(330699524);
  ios::sync_with_stdio(false);
  cout.precision(20);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> l[i] >> r[i];
    zp[l[i]] = zp[r[i]] = 0;
  }
  int x = 0;
  for (auto &i : zp) i.second = x++;
  for (int i = 0; i < n; i++) {
    l[i] = zp[l[i]];
    r[i] = zp[r[i]];
    a[l[i]] = {true, i};
    a[r[i]] = {false, i};
  }
  for (int i = 0; i < x; i++)
    if (!a[i].first) {
      ans[a[i].second] = get(i) - get(l[a[i].second]);
      upd(l[a[i].second]);
    }
  for (int i = 0; i < n; i++) cout << ans[i] << "\n";
  return 0;
}
