#include <bits/stdc++.h>
using namespace std;
int tree[800001];
pair<int, int> arr[200001];
void build(int node, int start, int end) {
  if (start == end) {
    tree[node] = 1;
  } else {
    int mid;
    mid = (start + end) / 2;
    build(2 * node, start, mid);
    build(2 * node + 1, mid + 1, end);
    tree[node] = tree[2 * node] + tree[2 * node + 1];
  }
}
void update(int node, int start, int end, int idx) {
  if (start == end) {
    tree[node] = 0;
  } else {
    int mid;
    mid = (start + end) / 2;
    if (idx <= mid) {
      update(2 * node, start, mid, idx);
    } else {
      update(2 * node + 1, mid + 1, end, idx);
    }
    tree[node] = tree[2 * node] + tree[2 * node + 1];
  }
}
int query(int node, int start, int end, int l, int r) {
  if (l > end or r < start) {
    return 0;
  } else if (l <= start and end <= r) {
    return tree[node];
  } else {
    int mid;
    mid = (start + end) / 2;
    int p1 = query(2 * node, start, mid, l, r);
    int p2 = query(2 * node + 1, mid + 1, end, l, r);
    return p1 + p2;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  pair<int, int> le[n + 1];
  for (int i = 1; i <= n; i++) {
    cin >> le[i].first >> arr[i].first;
    le[i].second = i;
    arr[i].second = i;
  }
  sort(arr + 1, arr + n + 1);
  int loc[n + 1];
  for (int i = 1; i <= n; i++) {
    loc[arr[i].second] = i;
  }
  build(1, 1, n);
  sort(le + 1, le + n + 1);
  int ans[n + 1];
  for (int i = 1; i <= n; i++) {
    ans[le[i].second] = query(1, 1, n, 1, loc[le[i].second]) - 1;
    update(1, 1, n, loc[le[i].second]);
  }
  for (int i = 1; i <= n; i++) cout << ans[i] << "\n";
  return 0;
}
