#include <bits/stdc++.h>
using namespace std;
template <class T>
using vv = vector<vector<T>>;
template <class T>
ostream &operator<<(ostream &os, const vector<T> &t) {
  os << "{";
  for (int(i) = 0; (i) < (t.size()); ++(i)) {
    os << t[i] << ",";
  }
  os << "}" << endl;
  return os;
}
template <class S, class T>
ostream &operator<<(ostream &os, const pair<S, T> &t) {
  return os << "(" << t.first << "," << t.second << ")";
}
const long long MOD = 1e9 + 7;
const int nn = 412345;
long long bit[nn + 1];
long long sum(int i) {
  i = nn - i - 10;
  long long s = 0;
  while (i > 0) {
    s += bit[i];
    i -= i & -i;
  }
  return s;
}
void add(int i, int x) {
  i = nn - i - 10;
  while (i <= nn) {
    bit[i] += x;
    i += i & -i;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(0);
  int n;
  cin >> n;
  vector<pair<int, int>> ps, ls;
  int x, y;
  vector<int> zip;
  for (int(i) = 0; (i) < (n); ++(i)) {
    cin >> x >> y;
    zip.push_back(x);
    zip.push_back(y);
    ps.emplace_back(x, y);
    ls.emplace_back(y, i);
  }
  sort((zip).begin(), (zip).end());
  for (pair<int, int> &p : ps) {
    p.first = lower_bound((zip).begin(), (zip).end(), p.first) - zip.begin();
    p.second = lower_bound((zip).begin(), (zip).end(), p.second) - zip.begin();
  }
  for (pair<int, int> &p : ls)
    p.first = lower_bound((zip).begin(), (zip).end(), p.first) - zip.begin();
  sort((ls).begin(), (ls).end());
  set<int> st;
  vector<int> re(n);
  for (pair<int, int> p : ls) {
    re[p.second] = sum(ps[p.second].first);
    add(ps[p.second].first, 1);
  }
  for (int(i) = 0; (i) < (n); ++(i)) cout << re[i] << endl;
  return 0;
}
