#include <bits/stdc++.h>
const int MAXN = 4e5 + 5;
int n;
std::vector<int> S;
struct Node {
  int l, r, id;
  Node(int l = 0, int r = 0, int id = 0) : l(l), r(r), id(id) {}
} a[MAXN];
struct BIT {
  int tree[MAXN];
  inline void add(int pos, int x) {
    for (; pos < MAXN; pos += ((pos) & (-(pos)))) tree[pos] += x;
  }
  inline int query(int pos) {
    int res = 0;
    for (; pos; pos -= ((pos) & (-(pos)))) res += tree[pos];
    return res;
  }
} bit;
int ans[MAXN];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i)
    scanf("%d%d", &a[i].l, &a[i].r), S.push_back(a[i].l), a[i].id = i;
  std::sort(S.begin(), S.end());
  S.erase(std::unique(S.begin(), S.end()), S.end());
  for (int i = 1; i <= n; ++i)
    a[i].l = std::lower_bound(S.begin(), S.end(), a[i].l) - S.begin() + 1;
  std::sort(a + 1, a + n + 1,
            [&](const Node &a, const Node &b) { return a.r < b.r; });
  for (int i = 1; i <= n; ++i) {
    ans[a[i].id] = i - 1 - bit.query(a[i].l - 1);
    bit.add(a[i].l, 1);
  }
  for (int i = 1; i <= n; ++i) printf("%d\n", ans[i]);
  return 0;
}
