#include <bits/stdc++.h>
using namespace std;
long long t, n, m, u, v, q, r, ql, qr, k, l, s, w, z, x, y, d, c;
const int N = 2e5 + 500;
const long long mod = 1e9 + 7;
const long long INF = 1LL << 52LL;
pair<pair<int, int>, int> R[N];
int tree[N << 4];
void modify(int l, int r, int i, int x) {
  if (l == r) {
    tree[i]++;
    return;
  }
  int mid = (l + r) >> 1;
  if (x <= mid)
    modify(l, mid, i + 1 + i, x);
  else
    modify(mid + 1, r, i + 2 + i, x);
  tree[i] = tree[i + 1 + i] + tree[i + 2 + i];
}
int sum(int l, int r, int i, int rl, int rr) {
  if (rl <= l && r <= rr) return tree[i];
  if (l > rr || rl > r) return 0;
  int mid = (l + r) >> 1;
  return sum(l, mid, i + 1 + i, rl, rr) + sum(mid + 1, r, i + 2 + i, rl, rr);
}
int sol[N];
map<int, int> M;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> R[i].first.first >> R[i].first.second;
    M[R[i].first.first];
    M[R[i].first.second];
    R[i].second = i;
  }
  int H = 0;
  for (auto i = M.begin(); i != M.end(); ++i) {
    i->second = ++H;
  }
  for (int i = 1; i <= n; ++i) {
    R[i].first.first = M[R[i].first.first];
    R[i].first.second = M[R[i].first.second];
  }
  sort(R + 1, R + 1 + n,
       [](const pair<pair<int, int>, int>& a,
          const pair<pair<int, int>, int>& b) {
         return a.first.second < b.first.second;
       });
  for (int i = 1; i <= n; ++i) {
    sol[R[i].second] = sum(1, H, 0, R[i].first.first, H);
    modify(1, H, 0, R[i].first.first);
  }
  for (int i = 1; i <= n; ++i) {
    cout << sol[i] << '\n';
  }
  return 0;
}
