#include <bits/stdc++.h>
const int M = 200005;
const int N = 1000001;
using namespace std;
int n, a[M], b[M], c[M], seg[8 * M], ans[M], mx;
vector<int> v;
map<int, int> m;
void update(int lo, int hi, int pos, int x) {
  if (lo > x || hi < x) return;
  if (lo == hi) {
    seg[pos]++;
    return;
  }
  int mid = (lo + hi) / 2;
  update(lo, mid, 2 * pos + 1, x);
  update(mid + 1, hi, 2 * pos + 2, x);
  seg[pos] = seg[2 * pos + 1] + seg[2 * pos + 2];
}
int get(int lo, int hi, int pos, int l, int r) {
  if (lo > r || hi < l) return 0;
  if (lo >= l && hi <= r) return seg[pos];
  int mid = (lo + hi) / 2;
  return get(lo, mid, 2 * pos + 1, l, r) + get(mid + 1, hi, 2 * pos + 2, l, r);
}
vector<pair<int, pair<int, int> > > u;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    scanf("%d%d", a + i, b + i);
    v.push_back(a[i]);
    v.push_back(b[i]);
  }
  sort(v.begin(), v.end());
  v.resize(unique(v.begin(), v.end()) - v.begin());
  mx = v.size() - 1;
  for (int i = 0; i < v.size(); i++) m[v[i]] = i;
  for (int i = 0; i < n; i++) a[i] = m[a[i]], b[i] = m[b[i]];
  for (int i = 0; i < n; i++) u.push_back(make_pair(a[i], make_pair(b[i], i)));
  sort(u.begin(), u.end());
  for (int i = n - 1; i >= 0; i--) {
    ans[u[i].second.second] = get(0, mx, 0, 0, u[i].second.first);
    update(0, mx, 0, u[i].second.first);
  }
  for (int i = 0; i < n; i++) printf("%d\n", ans[i]);
}

### Prompt

Your task is to create a cpp solution to the following problem:

You are given n segments on a line. There are no ends of some segments that coincide. For each segment find the number of segments it contains.

Input

The first line contains a single integer n (1 ≤ n ≤ 2·105) — the number of segments on a line.

Each of the next n lines contains two integers li and ri ( - 109 ≤ li < ri ≤ 109) — the coordinates of the left and the right ends of the i-th segment. It is guaranteed that there are no ends of some segments that coincide.

Output

Print n lines. The j-th of them should contain the only integer aj — the number of segments contained in the j-th segment.

Examples

Input

4
1 8
2 3
4 7
5 6


Output

3
0
1
0


Input

3
3 4
1 5
2 6


Output

0
1
1

### Response

```cpp
#include <bits/stdc++.h>
const int M = 200005;
const int N = 1000001;
using namespace std;
int n, a[M], b[M], c[M], seg[8 * M], ans[M], mx;
vector<int> v;
map<int, int> m;
void update(int lo, int hi, int pos, int x) {
  if (lo > x || hi < x) return;
  if (lo == hi) {
    seg[pos]++;
    return;
  }
  int mid = (lo + hi) / 2;
  update(lo, mid, 2 * pos + 1, x);
  update(mid + 1, hi, 2 * pos + 2, x);
  seg[pos] = seg[2 * pos + 1] + seg[2 * pos + 2];
}
int get(int lo, int hi, int pos, int l, int r) {
  if (lo > r || hi < l) return 0;
  if (lo >= l && hi <= r) return seg[pos];
  int mid = (lo + hi) / 2;
  return get(lo, mid, 2 * pos + 1, l, r) + get(mid + 1, hi, 2 * pos + 2, l, r);
}
vector<pair<int, pair<int, int> > > u;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    scanf("%d%d", a + i, b + i);
    v.push_back(a[i]);
    v.push_back(b[i]);
  }
  sort(v.begin(), v.end());
  v.resize(unique(v.begin(), v.end()) - v.begin());
  mx = v.size() - 1;
  for (int i = 0; i < v.size(); i++) m[v[i]] = i;
  for (int i = 0; i < n; i++) a[i] = m[a[i]], b[i] = m[b[i]];
  for (int i = 0; i < n; i++) u.push_back(make_pair(a[i], make_pair(b[i], i)));
  sort(u.begin(), u.end());
  for (int i = n - 1; i >= 0; i--) {
    ans[u[i].second.second] = get(0, mx, 0, 0, u[i].second.first);
    update(0, mx, 0, u[i].second.first);
  }
  for (int i = 0; i < n; i++) printf("%d\n", ans[i]);
}

```