#include <iostream>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <cmath>

using namespace std;

struct Node
{
    int x, y;
};

typedef Node node;

bool cmp(node a, node b)
{
    return a.x < b.x;
}

node arr[100010];
int range[200010][2];
int result[200010];

int main()
{
    int n, m;
    scanf("%d%d", &n, &m);

    for(int i = 0; i < m; i++)
    {
        scanf("%d%d", &arr[i].x, &arr[i].y);
    }

    sort(arr, arr + m, cmp);

    for(int i = 0; i < n; i++)
    {
        range[i][0] = i;
        range[i][1] = i;
    }

    for(int i = 0; i < m; i++)
    {
        range[arr[i].y][0] = range[arr[i].y - 1][0] = min(range[arr[i].y - 1][0], range[arr[i].y][0]);
        range[arr[i].y][1] = range[arr[i].y - 1][1] = max(range[arr[i].y - 1][1], range[arr[i].y][1]);
    }


    for(int i = 0; i < n; i++)
    {
        printf("%d", range[i][1]-range[i][0]+1);

        if(i < n - 1)
        {
            printf(" ");
        }
        else
        {
            printf("\n");
        }
    }

    return 0;
}
### Prompt

Please formulate a CPP solution to the following problem:

Example

Input

4 3
1000 1
2000 2
3000 3


Output

2 3 4 4

### Response

```cpp
#include <iostream>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <cmath>

using namespace std;

struct Node
{
    int x, y;
};

typedef Node node;

bool cmp(node a, node b)
{
    return a.x < b.x;
}

node arr[100010];
int range[200010][2];
int result[200010];

int main()
{
    int n, m;
    scanf("%d%d", &n, &m);

    for(int i = 0; i < m; i++)
    {
        scanf("%d%d", &arr[i].x, &arr[i].y);
    }

    sort(arr, arr + m, cmp);

    for(int i = 0; i < n; i++)
    {
        range[i][0] = i;
        range[i][1] = i;
    }

    for(int i = 0; i < m; i++)
    {
        range[arr[i].y][0] = range[arr[i].y - 1][0] = min(range[arr[i].y - 1][0], range[arr[i].y][0]);
        range[arr[i].y][1] = range[arr[i].y - 1][1] = max(range[arr[i].y - 1][1], range[arr[i].y][1]);
    }


    for(int i = 0; i < n; i++)
    {
        printf("%d", range[i][1]-range[i][0]+1);

        if(i < n - 1)
        {
            printf(" ");
        }
        else
        {
            printf("\n");
        }
    }

    return 0;
}
```