#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
mt19937 rng32(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rng64(chrono::steady_clock::now().time_since_epoch().count());
int N;
vector<pair<pair<int, int>, int>> event;
vector<int> ans;
priority_queue<int, vector<int>, greater<int>> heap;
vector<int> tree(1000007, 0);
void update(int node, int st, int en, int pos) {
  if (st > en || en < pos || pos < st) return;
  if (st == en) {
    tree[node]++;
    return;
  }
  update(node * 2, st, (st + en) / 2, pos);
  update(node * 2 + 1, (st + en) / 2 + 1, en, pos);
  tree[node] = tree[node * 2] + tree[node * 2 + 1];
}
int get(int node, int st, int en, int L, int R) {
  if (st > en || en < L || R < st || L > R) return 0;
  if (L <= st && en <= R) return tree[node];
  int p1 = get(node * 2, st, (st + en) / 2, L, R);
  int p2 = get(node * 2 + 1, (st + en) / 2 + 1, en, L, R);
  return (p1 + p2);
}
bool cmp(pair<pair<int, int>, int> a, pair<pair<int, int>, int> b) {
  if (a.first.first > b.first.first) return true;
  if (a.first.first == b.first.first && a.first.second < b.first.second)
    return true;
  return false;
}
void Input() {
  cin >> N;
  event.resize(N);
  ans.resize(N, 0);
  for (int i = 0; i < N; i++) {
    cin >> event[i].first.first >> event[i].first.second;
    event[i].second = i;
    heap.push(event[i].first.second);
  }
}
void Solve() {
  vector<int> mask(N + 1, -1);
  int cnt = 0;
  tree.resize(N * 4, 0);
  map<int, int> Map;
  while (!heap.empty()) {
    int z = heap.top();
    heap.pop();
    if (mask[cnt] == z) continue;
    cnt++;
    mask[cnt] = z;
    Map[z] = cnt;
  }
  for (int i = 0; i < N; i++)
    event[i].first.second = Map[event[i].first.second];
  sort(event.begin(), event.end(), cmp);
  for (int i = 0; i < N; i++) {
    if (event[i].first.second == 1)
      ans[event[i].second] = 0;
    else
      ans[event[i].second] = get(1, 1, N, 1, event[i].first.second - 1);
    update(1, 1, N, event[i].first.second);
  }
  for (int i = 0; i < N; i++) cout << ans[i] << '\n';
}
int main(int argc, char* argv[]) {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  Input();
  Solve();
  return 0;
}
