#include <bits/stdc++.h>
using namespace std;
template <typename T>
T nextInt() {
  T x = 0, p = 1;
  char ch;
  do {
    ch = getchar();
  } while (ch <= ' ');
  if (ch == '-') {
    p = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + (ch - '0');
    ch = getchar();
  }
  return x * p;
}
const int maxN = (int)4e5 + 10;
const int INF = (int)1e9;
const int mod = (int)1e9 + 7;
const long long LLINF = (long long)1e15;
int fw[maxN];
int answer[maxN];
vector<pair<int, int> > g[maxN];
int get(int r) {
  int ret = 0;
  for (; r >= 0; r = (r & (r + 1)) - 1) {
    ret += fw[r];
  }
  return ret;
}
void update(int r) {
  for (; r < maxN; r |= r + 1) {
    fw[r]++;
  }
}
int l[maxN];
int r[maxN];
int main() {
  int n;
  scanf("%d", &n);
  vector<int> x;
  for (int i = 0; i < n; ++i) {
    scanf("%d%d", l + i, r + i);
    x.push_back(l[i]);
    x.push_back(r[i]);
  }
  sort(x.begin(), x.end());
  for (int i = 0; i < n; ++i) {
    l[i] = lower_bound(x.begin(), x.end(), l[i]) - x.begin();
    r[i] = lower_bound(x.begin(), x.end(), r[i]) - x.begin();
    g[r[i]].push_back(make_pair(l[i], i));
  }
  for (int i = 0; i < maxN; ++i) {
    for (auto x : g[i]) {
      int l = x.first;
      int idx = x.second;
      answer[idx] = get(maxN - 1) - get(l);
      update(l);
    }
  }
  for (int i = 0; i < n; ++i) {
    printf("%d\n", answer[i]);
  }
  return 0;
}
