#include <bits/stdc++.h>
using namespace std;
struct Domino {
  int coordinate, height, input_index;
};
template <size_t Size>
class Segment_Tree {
 protected:
  array<int, 4 * Size> segment_tree;
  int ceil_log(const int &number) {
    int result = 0;
    for (int power_of_two = 1; power_of_two < number;
         power_of_two <<= 1, ++result)
      ;
    return result;
  }
  int leaf_to_index(const int &leaf) { return (1 << (height - 1)) - 1 + leaf; }
  int parent(const int &index) { return index / 2; }
  int left_child(const int &index) { return index * 2; }
  int right_child(const int &index) { return index * 2 + 1; }

 public:
  int height = ceil_log(Size) + 1;
  Segment_Tree() {
    for (int depth = 1; depth <= height; ++depth)
      for (int index = 1 << (depth - 1); index < 1 << depth; ++index)
        segment_tree[index] = 0;
  }
  void set(const int &leaf, const int &value) {
    segment_tree[leaf_to_index(leaf)] = value;
    for (int index = parent(leaf_to_index(leaf)); index >= 1;
         index = parent(index))
      segment_tree[index] = max(segment_tree[left_child(index)],
                                segment_tree[right_child(index)]);
  }
  int get(const int &start_leaf, const int &end_leaf) {
    int result = -1;
    int start_index, end_index;
    for (start_index = leaf_to_index(start_leaf),
        end_index = leaf_to_index(end_leaf);
         start_index < end_index;
         start_index = parent(start_index), end_index = parent(end_index)) {
      if (left_child(parent(start_index)) != start_index) {
        result = max(result, segment_tree[start_index]);
        ++start_index;
      }
      if (right_child(parent(end_index)) != end_index) {
        result = max(result, segment_tree[end_index]);
        --end_index;
      }
    }
    if (start_index == end_index)
      result = max(result, segment_tree[start_index]);
    return result;
  }
};
const int MAX_N = 1e5;
int n;
array<Domino, MAX_N + 1> dominos;
Segment_Tree<MAX_N> segment_tree;
bool has_next(const int &index) { return index < n; }
bool makes_next_to_fall(const int &index) {
  return dominos[index].coordinate + dominos[index].height - 1 >=
         dominos[index + 1].coordinate;
}
int farest_fallen_domino(const int &range_start, const int &range_end) {
  return segment_tree.get(range_start, range_end);
}
struct proxy {
  const int index;
  proxy(const int &index) : index(index) {}
  void operator=(const int &value) { segment_tree.set(index, value); }
  operator int() { return segment_tree.get(index, index); }
};
proxy farest_fallen_domino(const int &index) { return proxy(index); }
void optimize_IO() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
}
int main() {
  array<int, MAX_N + 1> z;
  optimize_IO();
  cin >> n;
  for (int input_index = 1; input_index <= n; ++input_index) {
    int x, h;
    cin >> x >> h;
    dominos[input_index] = {x, h, input_index};
  }
  sort(dominos.begin() + 1, dominos.begin() + n + 1,
       [](const Domino &comparand, const Domino &comparator) {
         return comparand.coordinate < comparator.coordinate;
       });
  for (int index = n; index >= 1; --index) {
    if (has_next(index) and makes_next_to_fall(index))
      farest_fallen_domino(index) = farest_fallen_domino(
          index + 1,
          distance(dominos.begin() + 1,
                   upper_bound(
                       dominos.begin() + 1, dominos.begin() + n + 1,
                       dominos[index].coordinate + dominos[index].height - 1,
                       [](const int &fallen_coordinate, const Domino &domino) {
                         return fallen_coordinate < domino.coordinate;
                       })));
    else
      farest_fallen_domino(index) = index;
  }
  for (int index = 1; index <= n; ++index)
    z[dominos[index].input_index] = farest_fallen_domino(index) - index + 1;
  for (int input_index = 1; input_index <= n; ++input_index)
    cout << z[input_index] << ' ';
  cout << '\n';
}

### Prompt

Please formulate a Cpp solution to the following problem:

Vasya is interested in arranging dominoes. He is fed up with common dominoes and he uses the dominoes of different heights. He put n dominoes on the table along one axis, going from left to right. Every domino stands perpendicular to that axis so that the axis passes through the center of its base. The i-th domino has the coordinate xi and the height hi. Now Vasya wants to learn for every domino, how many dominoes will fall if he pushes it to the right. Help him do that. 

Consider that a domino falls if it is touched strictly above the base. In other words, the fall of the domino with the initial coordinate x and height h leads to the fall of all dominoes on the segment [x + 1, x + h - 1].

<image>

Input

The first line contains integer n (1 ≤ n ≤ 105) which is the number of dominoes. Then follow n lines containing two integers xi and hi ( - 108 ≤ xi ≤ 108, 2 ≤ hi ≤ 108) each, which are the coordinate and height of every domino. No two dominoes stand on one point.

Output

Print n space-separated numbers zi — the number of dominoes that will fall if Vasya pushes the i-th domino to the right (including the domino itself).

Examples

Input

4
16 5
20 5
10 10
18 2


Output

3 1 4 1 

Input

4
0 10
1 5
9 10
15 10


Output

4 1 2 1 

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
struct Domino {
  int coordinate, height, input_index;
};
template <size_t Size>
class Segment_Tree {
 protected:
  array<int, 4 * Size> segment_tree;
  int ceil_log(const int &number) {
    int result = 0;
    for (int power_of_two = 1; power_of_two < number;
         power_of_two <<= 1, ++result)
      ;
    return result;
  }
  int leaf_to_index(const int &leaf) { return (1 << (height - 1)) - 1 + leaf; }
  int parent(const int &index) { return index / 2; }
  int left_child(const int &index) { return index * 2; }
  int right_child(const int &index) { return index * 2 + 1; }

 public:
  int height = ceil_log(Size) + 1;
  Segment_Tree() {
    for (int depth = 1; depth <= height; ++depth)
      for (int index = 1 << (depth - 1); index < 1 << depth; ++index)
        segment_tree[index] = 0;
  }
  void set(const int &leaf, const int &value) {
    segment_tree[leaf_to_index(leaf)] = value;
    for (int index = parent(leaf_to_index(leaf)); index >= 1;
         index = parent(index))
      segment_tree[index] = max(segment_tree[left_child(index)],
                                segment_tree[right_child(index)]);
  }
  int get(const int &start_leaf, const int &end_leaf) {
    int result = -1;
    int start_index, end_index;
    for (start_index = leaf_to_index(start_leaf),
        end_index = leaf_to_index(end_leaf);
         start_index < end_index;
         start_index = parent(start_index), end_index = parent(end_index)) {
      if (left_child(parent(start_index)) != start_index) {
        result = max(result, segment_tree[start_index]);
        ++start_index;
      }
      if (right_child(parent(end_index)) != end_index) {
        result = max(result, segment_tree[end_index]);
        --end_index;
      }
    }
    if (start_index == end_index)
      result = max(result, segment_tree[start_index]);
    return result;
  }
};
const int MAX_N = 1e5;
int n;
array<Domino, MAX_N + 1> dominos;
Segment_Tree<MAX_N> segment_tree;
bool has_next(const int &index) { return index < n; }
bool makes_next_to_fall(const int &index) {
  return dominos[index].coordinate + dominos[index].height - 1 >=
         dominos[index + 1].coordinate;
}
int farest_fallen_domino(const int &range_start, const int &range_end) {
  return segment_tree.get(range_start, range_end);
}
struct proxy {
  const int index;
  proxy(const int &index) : index(index) {}
  void operator=(const int &value) { segment_tree.set(index, value); }
  operator int() { return segment_tree.get(index, index); }
};
proxy farest_fallen_domino(const int &index) { return proxy(index); }
void optimize_IO() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
}
int main() {
  array<int, MAX_N + 1> z;
  optimize_IO();
  cin >> n;
  for (int input_index = 1; input_index <= n; ++input_index) {
    int x, h;
    cin >> x >> h;
    dominos[input_index] = {x, h, input_index};
  }
  sort(dominos.begin() + 1, dominos.begin() + n + 1,
       [](const Domino &comparand, const Domino &comparator) {
         return comparand.coordinate < comparator.coordinate;
       });
  for (int index = n; index >= 1; --index) {
    if (has_next(index) and makes_next_to_fall(index))
      farest_fallen_domino(index) = farest_fallen_domino(
          index + 1,
          distance(dominos.begin() + 1,
                   upper_bound(
                       dominos.begin() + 1, dominos.begin() + n + 1,
                       dominos[index].coordinate + dominos[index].height - 1,
                       [](const int &fallen_coordinate, const Domino &domino) {
                         return fallen_coordinate < domino.coordinate;
                       })));
    else
      farest_fallen_domino(index) = index;
  }
  for (int index = 1; index <= n; ++index)
    z[dominos[index].input_index] = farest_fallen_domino(index) - index + 1;
  for (int input_index = 1; input_index <= n; ++input_index)
    cout << z[input_index] << ' ';
  cout << '\n';
}

```