#include <bits/stdc++.h>
using namespace std;
const long long sz = 200005;
long long mod = 1e9 + 7;
long long n, m, t, k;
vector<long long> BIT(sz, 0);
void Update(long long in, long long x) {
  for (long long i = in; i < sz; i += i & (-i)) BIT[i] += 1;
}
long long Query(long long in) {
  long long ans = 0;
  for (long long i = in; i >= 1; i -= i & (-i)) ans += BIT[i];
  return ans;
}
bool cmp(pair<long long, long long> a, pair<long long, long long> b) {
  if (a.second != b.second) return (a.second < b.second);
  return (a.first > b.first);
}
long long Check(pair<long long, long long> a, pair<long long, long long> b) {
  if (a.second < b.first) return (b.first - a.second);
  if (a.first > b.second) return (a.first - b.second);
  return 0;
}
vector<long long> fac(sz, 1);
void init() {
  for (long long i = 1; i < sz; i++) fac[i] = (fac[i - 1] * i) % mod;
}
long long Power(long long a, long long b) {
  if (a == 0) return 0;
  if (b == 0) return 1;
  long long ans = Power((a * a) % mod, b / 2);
  if (b & 1) return (a * ans) % mod;
  return ans % mod;
}
long long Inv(long long a) { return Power(a, mod - 2); }
long long NCR(long long n, long long r) {
  if (r > n) return 0;
  long long ans =
      (fac[n] * ((Inv(fac[n - r])) % mod * (Inv(fac[r])) % mod) % mod) % mod;
  return ans % mod;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  vector<pair<long long, long long> > v(n), vv;
  map<pair<long long, long long>, long long> mp;
  for (long long i = 0; i < n; i++) {
    cin >> v[i].first >> v[i].second;
    mp[v[i]] = i;
  }
  sort(v.begin(), v.end());
  map<long long, long long> mp1, mp2;
  for (long long i = 0; i < n; i++) mp1[v[i].second] = 0;
  long long x = 1;
  for (auto i : mp1) {
    mp2[i.first] = x;
    x++;
  }
  map<long long, long long> ans;
  for (long long i = n - 1; i >= 0; i--) {
    long long x = mp2[v[i].second];
    ans[mp[v[i]]] = Query(x);
    Update(x, 1);
  }
  for (auto i : ans) cout << i.second << endl;
}
