#include <bits/stdc++.h>
template <class T>
struct fenwick_tree {
  std::vector<T> v;
  explicit fenwick_tree(size_t n) : v(n + 1) {}
  explicit fenwick_tree(size_t n, T constant) {
    v[0] = 0;
    for (size_t i = 0; i + (i & -i) <= n; i++) v[i + (i & -i)] += v[i];
  }
  explicit fenwick_tree(std::vector<T> x) : v(x.size() + 1) {
    for (size_t i = 0; i < x.size(); i++) v[i + 1] = x[i];
    for (size_t i = 1; i + (i & -i) < x.size(); i++) v[i + (i & -i)] += v[i];
  }
  void add(size_t k, T a) {
    for (++k; k < v.size(); k += k & -k) v[k] += a;
  }
  T sum(int k) {
    T s = 0;
    for (++k; k > 0; k -= k & -k) s += v[k];
    return s;
  }
  T get(int k) {
    k++;
    return sum(k) - sum(k - 1);
  }
};
int main() {
  std::ios_base::sync_with_stdio(false);
  size_t n;
  std::cin >> n;
  std::vector<std::tuple<size_t, size_t, size_t, size_t>> segments(n);
  std::vector<size_t *> segment_ends(n * 2);
  for (size_t i = 0; i < n; i++) {
    int l, r;
    std::cin >> l;
    std::cin >> r;
    segments[i] = std::make_tuple(static_cast<size_t>(l + 1000000000),
                                  static_cast<size_t>(r + 1000000000), i, 0);
    segment_ends[i] = &std::get<0>(segments[i]);
    segment_ends[i + n] = &std::get<1>(segments[i]);
  }
  std::sort(segment_ends.begin(), segment_ends.end(),
            [&](size_t *a, size_t *b) -> bool { return *a < *b; });
  *segment_ends[0] = 0;
  for (size_t i = 1; i < n * 2; i++)
    *segment_ends[i] = *segment_ends[i - 1] + 1;
  std::sort(segments.begin(), segments.end(),
            [&](std::tuple<size_t, size_t, size_t, size_t> a,
                std::tuple<size_t, size_t, size_t, size_t> b) -> bool {
              return std::get<0>(a) > std::get<0>(b);
            });
  fenwick_tree<size_t> fw = fenwick_tree<size_t>(n * 2);
  for (auto &s : segments) {
    auto r = static_cast<int>(std::get<1>(s));
    size_t count = fw.sum(r);
    std::get<3>(s) = count;
    fw.add(std::get<1>(s), 1);
  }
  std::sort(segments.begin(), segments.end(),
            [&](std::tuple<size_t, size_t, size_t, size_t> a,
                std::tuple<size_t, size_t, size_t, size_t> b) -> bool {
              return std::get<2>(a) < std::get<2>(b);
            });
  for (auto s : segments) std::cout << std::get<3>(s) << "\n";
  return 0;
}
