#include <bits/stdc++.h>
using namespace std;
const long long M = 1e9 + 7, MAX = 2e9 + 9;
map<int, int> f;
void upd(int vv, int x) {
  for (long long v = vv; v < MAX; v += v & -v) f[v] += x;
}
int gt(int x) {
  int ret = 0;
  for (; x; x -= x & -x) ret += f[x];
  return ret;
}
vector<pair<pair<int, int>, int> > v;
int n, ans[200009], k;
bool cmp(pair<pair<int, int>, int> a, pair<pair<int, int>, int> b) {
  return a.first.second < b.first.second;
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> n;
  for (int i = 0, l, r; i < n; i++)
    cin >> l >> r, v.push_back({{l + M, r + M}, i});
  sort(v.begin(), v.end(), cmp);
  for (auto i : v)
    upd(i.first.first, +1), ans[i.second] = k + 1 - gt(i.first.first - 1), k++;
  for (int i = 0; i < n; i++) cout << ans[i] - 1 << '\n';
}
