#include <bits/stdc++.h>
using namespace std;
const int N = 200010;
long long seg[10 * N], Hash[2 * N], ans[N];
pair<pair<long long, long long>, long long> a[N];
map<long long, long long> Map;
void update(int i, int j, long long val, int p = 1, int L = 1, int R = 2 * N) {
  if (L > j || R < i) return;
  if (L == i && L == R) {
    seg[p]++;
    return;
  }
  int mid = L + R >> 1;
  update(i, j, val, p * 2, L, mid);
  update(i, j, val, p * 2 + 1, mid + 1, R);
  seg[p] = seg[p * 2] + seg[p * 2 + 1];
}
long long query(int i, int j, int p = 1, int L = 1, int R = 2 * N) {
  if (L > j || R < i) return 0;
  if (L >= i && R <= j) return seg[p];
  int mid = L + R >> 1;
  long long c1 = query(i, j, p * 2, L, mid);
  long long c2 = query(i, j, p * 2 + 1, mid + 1, R);
  return c1 + c2;
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i].first.first >> a[i].first.second;
    Map[a[i].first.first];
    Map[a[i].first.second];
    a[i].second = i;
  }
  int cnt = 0;
  for (map<long long, long long>::iterator it = Map.begin(); it != Map.end();
       it++) {
    it->second = ++cnt;
  }
  for (int i = 0; i < n; i++) {
    a[i].first.first = Map[a[i].first.first];
    a[i].first.second = Map[a[i].first.second];
  }
  sort(a, a + n, greater<pair<pair<long long, long long>, long long> >());
  for (int i = 0; i < n; i++) {
    ans[a[i].second] = query(a[i].first.first, a[i].first.second);
    update(a[i].first.second, a[i].first.second, 1);
  }
  for (int i = 0; i < n; i++) cout << ans[i] << endl;
  return 0;
}

### 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>
using namespace std;
const int N = 200010;
long long seg[10 * N], Hash[2 * N], ans[N];
pair<pair<long long, long long>, long long> a[N];
map<long long, long long> Map;
void update(int i, int j, long long val, int p = 1, int L = 1, int R = 2 * N) {
  if (L > j || R < i) return;
  if (L == i && L == R) {
    seg[p]++;
    return;
  }
  int mid = L + R >> 1;
  update(i, j, val, p * 2, L, mid);
  update(i, j, val, p * 2 + 1, mid + 1, R);
  seg[p] = seg[p * 2] + seg[p * 2 + 1];
}
long long query(int i, int j, int p = 1, int L = 1, int R = 2 * N) {
  if (L > j || R < i) return 0;
  if (L >= i && R <= j) return seg[p];
  int mid = L + R >> 1;
  long long c1 = query(i, j, p * 2, L, mid);
  long long c2 = query(i, j, p * 2 + 1, mid + 1, R);
  return c1 + c2;
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i].first.first >> a[i].first.second;
    Map[a[i].first.first];
    Map[a[i].first.second];
    a[i].second = i;
  }
  int cnt = 0;
  for (map<long long, long long>::iterator it = Map.begin(); it != Map.end();
       it++) {
    it->second = ++cnt;
  }
  for (int i = 0; i < n; i++) {
    a[i].first.first = Map[a[i].first.first];
    a[i].first.second = Map[a[i].first.second];
  }
  sort(a, a + n, greater<pair<pair<long long, long long>, long long> >());
  for (int i = 0; i < n; i++) {
    ans[a[i].second] = query(a[i].first.first, a[i].first.second);
    update(a[i].first.second, a[i].first.second, 1);
  }
  for (int i = 0; i < n; i++) cout << ans[i] << endl;
  return 0;
}

```