#include <bits/stdc++.h>
const long double EPS = 1e-10;
const long long int MOD = 1000000007ll;
const long long int mod1 = 1000000009ll;
const long long int mod2 = 1100000009ll;
int INF = 2147483645;
long long int INFINF = 9223372036854775807;
int debug = 0;
using namespace std;
void print(int a[], int s, int e) {
  for (int i = s; i <= e; i++) cout << a[i] << " ";
  cout << "\n";
}
void print(vector<int> &v, int s, int e) {
  for (int i = s; i <= e; i++) cout << v[i] << " ";
  cout << "\n";
}
void print(vector<int> &v) {
  for (int x : v) cout << x << " ";
  cout << "\n";
}
long long int bit_count(long long int _x) {
  long long int _ret = 0;
  while (_x) {
    if (_x % 2 == 1) _ret++;
    _x /= 2;
  }
  return _ret;
}
long long int bit(long long int _mask, long long int _i) {
  return (_mask & (1 << _i)) == 0 ? 0 : 1;
}
long long int powermod(long long int _a, long long int _b, long long int _m) {
  long long int _r = 1;
  while (_b) {
    if (_b % 2 == 1) _r = (_r * _a) % _m;
    _b /= 2;
    _a = (_a * _a) % _m;
  }
  return _r;
}
long long int add(long long int a, long long int b, long long int m = MOD) {
  long long int x = a + b;
  while (x >= m) x -= m;
  return x;
}
long long int sub(long long int a, long long int b, long long int m = MOD) {
  long long int x = a - b;
  while (x < 0) x += m;
  return x;
}
long long int mul(long long int a, long long int b, long long int m = MOD) {
  long long int x = a * b;
  x %= m;
  return x;
}
int n;
int ans[200010];
int l[200010], r[200010];
int segtree[200010 * 2 * 4];
set<int> Set;
map<int, int> Map;
vector<int> v;
int tot = 1;
bool compare(int x, int y) {
  pair<int, int> a = {l[x], r[x]};
  pair<int, int> b = {l[y], r[y]};
  if (a.second == b.second) return a.first < b.first;
  return a.second < b.second;
}
void update(int s, int e, int x, int idx) {
  if (s == e) {
    segtree[idx]++;
    return;
  }
  int mid = (s + e) >> 1;
  if (x <= mid)
    update(s, mid, x, 2 * idx + 1);
  else
    update(mid + 1, e, x, 2 * idx + 2);
  segtree[idx] = segtree[2 * idx + 1] + segtree[2 * idx + 2];
}
int query(int s, int e, int x, int y, int idx) {
  if (s == x && e == y) return segtree[idx];
  int mid = (s + e) >> 1;
  if (y <= mid)
    return query(s, mid, x, y, 2 * idx + 1);
  else if (x > mid)
    return query(mid + 1, e, x, y, 2 * idx + 2);
  return query(s, mid, x, mid, 2 * idx + 1) +
         query(mid + 1, e, mid + 1, y, 2 * idx + 2);
}
int main() {
  srand(time(NULL));
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &l[i]);
    scanf("%d", &r[i]);
    Set.insert(l[i]);
    Set.insert(r[i]);
  }
  for (set<int>::iterator it = Set.begin(); it != Set.end(); it++) {
    Map[*it] = tot;
    tot++;
  }
  tot--;
  for (int i = 1; i <= n; i++) {
    l[i] = Map[l[i]];
    r[i] = Map[r[i]];
    v.push_back(i);
  }
  sort(v.begin(), v.end(), compare);
  for (int x : v) {
    ans[x] = query(1, tot, l[x], r[x], 0);
    update(1, tot, l[x], 0);
  }
  for (int i = 1; i <= n; i++) cout << ans[i] << "\n";
  return 0;
}
