#include <bits/stdc++.h>
using namespace std;
template <typename T>
void read(T& x) {
  x = 0;
  char ch = getchar();
  long long f = 1;
  while (!isdigit(ch)) {
    if (ch == '-') f *= -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + ch - 48;
    ch = getchar();
  }
  x *= f;
}
template <typename T, typename... Args>
void read(T& first, Args&... args) {
  read(first);
  read(args...);
}
template <typename T>
void write(T arg) {
  T x = arg;
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  if (x > 9) {
    write(x / 10);
  }
  putchar(x % 10 + '0');
}
template <typename T, typename... Ts>
void write(T arg, Ts... args) {
  write(arg);
  if (sizeof...(args) != 0) {
    putchar(' ');
    write(args...);
  }
}
using namespace std;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
const int N = 2e6 + 5;
int n;
struct BIT {
  int tree[1000005];
  int ed = 1e6 + 5;
  void init() { memset(tree, 0, sizeof(tree)); }
  int lowbit(int k) { return k & -k; }
  void add(int x, int k) {
    while (x <= ed) {
      tree[x] += k;
      x += lowbit(x);
    }
  }
  int sum(int x) {
    int ans = 0;
    while (x != 0) {
      ans += tree[x];
      x -= lowbit(x);
    }
    return ans;
  }
} bit;
int ans[N];
struct node {
  int x, y, id;
  bool operator<(const node& no) const {
    if (x == no.x) return y < no.y;
    return x > no.x;
  }
} p[N];
int a[N], b[N];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> p[i].x >> p[i].y, p[i].id = i;
  sort(p + 1, p + 1 + n);
  for (int i = 1; i <= n; i++) a[i] = p[i].y;
  sort(a + 1, a + 1 + n);
  int len = unique(a + 1, a + 1 + n) - a - 1;
  for (int i = 1; i <= n; i++) {
    int idx = lower_bound(a + 1, a + 1 + len, p[i].y) - a;
    ans[p[i].id] += bit.sum(idx);
    bit.add(idx, 1);
  }
  for (int i = 1; i <= n; i++) cout << ans[i] << endl;
}
