#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 7, NADA = -1;
const long long INFIN = 1e9;
int n, q;
struct nst {
  int first, second, id;
  nst(int ff, int ss, int idd) {
    first = ff;
    second = ss;
    id = idd;
  }
  nst() {}
};
nst xt[MAXN];
int ans[MAXN];
vector<int> fe_ENT, fd_ENT, soma_ENT, fe_SAI, fd_SAI, soma_SAI;
int create_ENT() {
  fe_ENT.push_back(NADA);
  fd_ENT.push_back(NADA);
  soma_ENT.push_back(0);
  return (int)soma_ENT.size() - 1;
}
bool comp(nst pi, nst pj) {
  int c1 = pi.second - pi.first;
  int c2 = pj.second - pj.first;
  if (c1 == c2) return pi.first < pj.first;
  return c1 < c2;
}
void update_ENT(int idx, long long l, long long r, int pos) {
  if (l == r) {
    soma_ENT[idx]++;
    return;
  }
  long long m = (r == l + 1) ? l : (l + r) / 2;
  if (pos <= m) {
    if (fe_ENT[idx] == NADA) {
      int novo = create_ENT();
      fe_ENT[idx] = novo;
    }
    update_ENT(fe_ENT[idx], l, m, pos);
  } else {
    if (fd_ENT[idx] == NADA) {
      int novo = create_ENT();
      fd_ENT[idx] = novo;
    }
    update_ENT(fd_ENT[idx], m + 1, r, pos);
  }
  int soma_esq = (fe_ENT[idx] == NADA) ? 0 : soma_ENT[fe_ENT[idx]];
  int soma_dir = (fd_ENT[idx] == NADA) ? 0 : soma_ENT[fd_ENT[idx]];
  soma_ENT[idx] = soma_esq + soma_dir;
}
int query_ENT(int idx, long long l, long long r, int ql, int qr) {
  if (l > qr || r < ql) return 0;
  if (l >= ql && r <= qr) return soma_ENT[idx];
  long long m = (r == l + 1) ? l : (l + r) / 2;
  int soma_esq =
      (fe_ENT[idx] == NADA) ? 0 : query_ENT(fe_ENT[idx], l, m, ql, qr);
  int soma_dir =
      (fd_ENT[idx] == NADA) ? 0 : query_ENT(fd_ENT[idx], m + 1, r, ql, qr);
  return soma_esq + soma_dir;
}
int create_SAI() {
  fe_SAI.push_back(NADA);
  fd_SAI.push_back(NADA);
  soma_SAI.push_back(0);
  return (int)soma_SAI.size() - 1;
}
void update_SAI(int idx, long long l, long long r, int pos) {
  if (l == r) {
    soma_SAI[idx]++;
    return;
  }
  long long m = (r == l + 1) ? l : (l + r) / 2;
  if (pos <= m) {
    if (fe_SAI[idx] == NADA) {
      int novo = create_SAI();
      fe_SAI[idx] = novo;
    }
    update_SAI(fe_SAI[idx], l, m, pos);
  } else {
    if (fd_SAI[idx] == NADA) {
      int novo = create_SAI();
      fd_SAI[idx] = novo;
    }
    update_SAI(fd_SAI[idx], m + 1, r, pos);
  }
  int soma_esq = (fe_SAI[idx] == NADA) ? 0 : soma_SAI[fe_SAI[idx]];
  int soma_dir = (fd_SAI[idx] == NADA) ? 0 : soma_SAI[fd_SAI[idx]];
  soma_SAI[idx] = soma_esq + soma_dir;
}
int query_SAI(int idx, long long l, long long r, int ql, int qr) {
  if (l > qr || r < ql) return 0;
  if (l >= ql && r <= qr) return soma_SAI[idx];
  long long m = (r == l + 1) ? l : (l + r) / 2;
  int soma_esq =
      (fe_SAI[idx] == NADA) ? 0 : query_SAI(fe_SAI[idx], l, m, ql, qr);
  int soma_dir =
      (fd_SAI[idx] == NADA) ? 0 : query_SAI(fd_SAI[idx], m + 1, r, ql, qr);
  return soma_esq + soma_dir;
}
int main() {
  scanf("%d", &n);
  int raiz_ENT = create_ENT();
  int raiz_SAI = create_SAI();
  for (int i = 0; i < n; i++) {
    int x1, x2;
    scanf("%d %d", &x1, &x2);
    xt[i] = nst(x1, x2, i);
  }
  sort(xt, xt + n, comp);
  for (int i = 0; i < n; i++) {
    int caso1 = query_SAI(raiz_SAI, -INFIN, INFIN, -INFIN, xt[i].first - 1) +
                query_ENT(raiz_ENT, -INFIN, INFIN, xt[i].second + 1, INFIN);
    int caso2 = query_ENT(raiz_ENT, -INFIN, INFIN, -INFIN, xt[i].first - 1) -
                query_SAI(raiz_SAI, -INFIN, INFIN, -INFIN, xt[i].first);
    int caso3 = query_SAI(raiz_ENT, -INFIN, INFIN, xt[i].second + 1, INFIN) -
                query_ENT(raiz_SAI, -INFIN, INFIN, xt[i].second + 1, INFIN);
    ans[xt[i].id] = i + 1 - (caso1 + caso2 + caso3) - 1;
    update_ENT(raiz_ENT, -INFIN, INFIN, xt[i].first);
    update_SAI(raiz_SAI, -INFIN, INFIN, xt[i].second);
  }
  for (int i = 0; i < n; i++) {
    cout << ans[i] << endl;
  }
}
