#include <bits/stdc++.h>
using namespace std;
vector<int64_t> tree(2 * (4e5 + 1));
void build(int64_t n) {
  for (int64_t i = n - 1; i > 0; --i) tree[i] = tree[i << 1] + tree[i << 1 | 1];
}
void modify(int64_t pos, int64_t val, int64_t n) {
  pos += n;
  for (tree[pos] = val; pos > 1; pos >>= 1) {
    tree[pos >> 1] = (tree[pos] + tree[pos ^ 1]);
  }
}
int sum(int64_t l, int64_t r, int64_t n) {
  int ans = 0;
  for (l += n, r = r + n + 1; l < r; l >>= 1, r >>= 1) {
    if (l & 1) ans += tree[l++];
    if (r & 1) ans += tree[--r];
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  map<pair<int, int>, int> pts;
  map<int, int> adj, blookup;
  vector<int> lookup(2 * n);
  int x, y;
  for (int i = 0; i < n; i++) {
    cin >> x >> y;
    lookup[i << 1] = x;
    lookup[i << 1 | 1] = y;
    pts[{x, y}] = pts[{y, x}] = i;
    adj[x] = y;
    adj[y] = x;
  }
  n *= 2;
  sort(lookup.begin(), lookup.end());
  for (int i = 0; i < n; i++) {
    blookup[lookup[i]] = i;
  }
  int sz;
  map<int, int> ans;
  set<int> en;
  for (int i = 0; i < n; i++) {
    if (en.find(i) != en.end()) {
      en.erase(i);
      ans[pts[{lookup[i], adj[lookup[i]]}]] =
          sum(blookup[adj[lookup[i]]], i, n);
      modify(blookup[adj[lookup[i]]], 1, n);
    } else {
      en.insert(blookup[adj[lookup[i]]]);
    }
  }
  for (auto it : ans) cout << it.second << "\n";
}
