#include <bits/stdc++.h>
using namespace std;
const int maxn = 200010;
struct node {
  int l, r;
  int id;
  node() {}
  node(int l, int r) : l(l), r(r) {}
  bool operator<(const node& other) const { return r < other.r; }
} nds[maxn];
int b[maxn << 1];
int k;
int Find(int x) { return lower_bound(b, b + k, x) - b + 1; }
int c[maxn << 1];
int ans[maxn];
inline int lowbit(int x) { return x & (-x); }
void update(int x) {
  while (x <= 400010) {
    c[x]++;
    x += lowbit(x);
  }
}
int query(int x) {
  int ans = 0;
  while (x) {
    ans += c[x];
    x -= lowbit(x);
  }
  return ans;
}
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    scanf("%d%d", &nds[i].l, &nds[i].r);
    nds[i].id = i;
    b[i << 1] = nds[i].l;
    b[(i << 1) + 1] = nds[i].r;
  }
  k = n << 1;
  sort(b, b + k);
  k = unique(b, b + k) - b;
  for (int i = 0; i < n; i++) {
    nds[i].l = Find(nds[i].l);
    nds[i].r = Find(nds[i].r);
  }
  sort(nds, nds + n);
  int tot = 0;
  for (int i = 0; i < n; i++) {
    int q = query(nds[i].l);
    ans[nds[i].id] = tot - q;
    update(nds[i].l);
    tot++;
  }
  for (int i = 0; i < n; i++) {
    printf("%d\n", ans[i]);
  }
  return 0;
}
