#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef pair<int, int> pii;

int main(){
  int n, m;
  std::cin >> n >> m;
  vector<pii> robot(m);
  for (int i = 0; i < m; i++) {
    std::cin >> robot[i].first >> robot[i].second;
    robot[i].second--;
  }
  sort(robot.begin(), robot.end());
  reverse(robot.begin(), robot.end());
  vector<pii> range(n);
  for (int i = 0; i < n; i++) {
    range[i] = pii(i, i);
  }
  for (int i = 0; i < m; i++) {
    int lane = robot[i].second;
    range[lane].first = min(range[lane].first, range[lane + 1].first);
    range[lane].second = max(range[lane].second, range[lane + 1].second);
    range[lane + 1].first = min(range[lane].first, range[lane + 1].first);
    range[lane + 1].second = max(range[lane].second, range[lane + 1].second);
  }
  vector<int> ans(n + 1, 0);
  for (int i = 0; i < n; i++) {
    // std::cout << range[i].first << std::endl;
    // std::cout << range[i].second << std::endl;
    ans[range[i].first]++;
    ans[range[i].second + 1]--;
  }
  for (int i = 0; i < n - 1; i++) {
    ans[i + 1] += ans[i];
  }
  for (int i = 0; i < n; i++) {
    std::cout << ans[i];
    if(i != n - 1)std::cout << " ";
  }
  std::cout << std::endl;
  return 0;
}
### Prompt

Develop a solution in CPP to the problem described below:

Example

Input

4 3
1000 1
2000 2
3000 3


Output

2 3 4 4

### Response

```cpp
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef pair<int, int> pii;

int main(){
  int n, m;
  std::cin >> n >> m;
  vector<pii> robot(m);
  for (int i = 0; i < m; i++) {
    std::cin >> robot[i].first >> robot[i].second;
    robot[i].second--;
  }
  sort(robot.begin(), robot.end());
  reverse(robot.begin(), robot.end());
  vector<pii> range(n);
  for (int i = 0; i < n; i++) {
    range[i] = pii(i, i);
  }
  for (int i = 0; i < m; i++) {
    int lane = robot[i].second;
    range[lane].first = min(range[lane].first, range[lane + 1].first);
    range[lane].second = max(range[lane].second, range[lane + 1].second);
    range[lane + 1].first = min(range[lane].first, range[lane + 1].first);
    range[lane + 1].second = max(range[lane].second, range[lane + 1].second);
  }
  vector<int> ans(n + 1, 0);
  for (int i = 0; i < n; i++) {
    // std::cout << range[i].first << std::endl;
    // std::cout << range[i].second << std::endl;
    ans[range[i].first]++;
    ans[range[i].second + 1]--;
  }
  for (int i = 0; i < n - 1; i++) {
    ans[i + 1] += ans[i];
  }
  for (int i = 0; i < n; i++) {
    std::cout << ans[i];
    if(i != n - 1)std::cout << " ";
  }
  std::cout << std::endl;
  return 0;
}
```