#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const int SIZE = 1e6 + 5;
const long long INF = 1LL << 58;
const double eps = 1e-13;
int fw[400009];
void up(int x, int v) {
  for (; x < 400009; x += x & (-x)) fw[x] += v;
}
int qu(int x) {
  int ans = 0;
  for (; x; x -= x & (-x)) ans += fw[x];
  return ans;
}
vector<int> disc;
pair<pair<int, int>, int> q[200009];
int ans[200009];
int main() {
  int(n);
  scanf("%d", &n);
  for (int i = 0; i < (n); ++i) {
    scanf("%d%d", &(q[i].first.second), &(q[i].first.first));
    q[i].second = i;
    disc.push_back(q[i].first.first);
    disc.push_back(q[i].first.second);
  }
  sort((disc).begin(), (disc).end());
  for (int i = 0; i < (n); ++i) {
    q[i].first.first =
        lower_bound((disc).begin(), (disc).end(), q[i].first.first) -
        disc.begin() + 1;
    q[i].first.second =
        lower_bound((disc).begin(), (disc).end(), q[i].first.second) -
        disc.begin() + 1;
  }
  sort(q, q + n);
  for (int i = 0; i < (n); ++i) {
    ans[q[i].second] = qu(400006 - q[i].first.second);
    up(400006 - q[i].first.second, 1);
  }
  for (int i = 0; i < (n); ++i) printf("%d\n", ans[i]);
}
