#include <bits/stdc++.h>
using namespace std;
const int N = 2e6;
int t[N];
void add(int p) {
  for (; p < N - 20; p |= p + 1) t[p]++;
}
int sum(int r) {
  int res = 0;
  for (; r >= 0; r = (r & (r + 1)) - 1) res += t[r];
  return res;
}
struct segment {
  int from, to;
  int index;
  bool operator<(const segment& that) const {
    if (to != that.to) return to < that.to;
    return from > that.from;
  }
};
int ans[N];
int main() {
  vector<int> x;
  int n;
  cin >> n;
  vector<segment> segments(n);
  for (int i = 0; i < n; ++i) {
    cin >> segments[i].from >> segments[i].to;
    segments[i].index = i;
    x.push_back(segments[i].from);
    x.push_back(segments[i].to);
  }
  sort(x.begin(), x.end());
  sort(segments.begin(), segments.end());
  for (int i = 0; i < n; ++i) {
    int from = lower_bound(x.begin(), x.end(), segments[i].from) - x.begin();
    int to = lower_bound(x.begin(), x.end(), segments[i].to) - x.begin();
    ans[segments[i].index] = sum(N - 21) - sum(from - 1);
    add(from);
  }
  for (int i = 0; i < n; ++i) cout << ans[i] << endl;
}
