#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
#define REP(i, N) for(ll i = 0; i < N; ++i)
#define FOR(i, a, b) for(ll i = a; i < b; ++i)
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define INF (long long)1000000000
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main(void) {
	int n, m;
	cin>>n>>m;
	vector<P> arm(m);
	REP(i, m) {
		cin>>arm[i].first>>arm[i].second;
		--arm[i].second;
	}
	sort(ALL(arm));
	vector<ll> cnt(n, -1);    //?????????
	vector<ll> bef(m);        // ??\????????§??????????¢????????????
	REP(i, m) {
		bef[i] = cnt[arm[i].second];
		cnt[arm[i].second] = i;
	}
	vector<ll> pos(n, 1); // ??????¨????????????§???
	vector<P> trns(m);    // ??§????????????????
	REP(i, m) {
		if(bef[i] == -1) {
			pos[arm[i].second + 1] = pos[arm[i].second] = pos[arm[i].second] + pos[arm[i].second + 1];
		} else {
			ll buf = pos[arm[i].second];
			pos[arm[i].second] += pos[arm[i].second + 1] - trns[bef[i]].first;
			pos[arm[i].second + 1] += buf - trns[bef[i]].second;
		}
		trns[i].first = pos[arm[i].second + 1];
		trns[i].second = pos[arm[i].second];
	}
	REP(i, n) {
		cout<<pos[i];
		if(i != n - 1) cout<<' ';
		else cout<<endl;
	}
}
### Prompt

Construct a Cpp code solution to the problem outlined:

Example

Input

4 3
1000 1
2000 2
3000 3


Output

2 3 4 4

### Response

```cpp
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
#define REP(i, N) for(ll i = 0; i < N; ++i)
#define FOR(i, a, b) for(ll i = a; i < b; ++i)
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define INF (long long)1000000000
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main(void) {
	int n, m;
	cin>>n>>m;
	vector<P> arm(m);
	REP(i, m) {
		cin>>arm[i].first>>arm[i].second;
		--arm[i].second;
	}
	sort(ALL(arm));
	vector<ll> cnt(n, -1);    //?????????
	vector<ll> bef(m);        // ??\????????§??????????¢????????????
	REP(i, m) {
		bef[i] = cnt[arm[i].second];
		cnt[arm[i].second] = i;
	}
	vector<ll> pos(n, 1); // ??????¨????????????§???
	vector<P> trns(m);    // ??§????????????????
	REP(i, m) {
		if(bef[i] == -1) {
			pos[arm[i].second + 1] = pos[arm[i].second] = pos[arm[i].second] + pos[arm[i].second + 1];
		} else {
			ll buf = pos[arm[i].second];
			pos[arm[i].second] += pos[arm[i].second + 1] - trns[bef[i]].first;
			pos[arm[i].second + 1] += buf - trns[bef[i]].second;
		}
		trns[i].first = pos[arm[i].second + 1];
		trns[i].second = pos[arm[i].second];
	}
	REP(i, n) {
		cout<<pos[i];
		if(i != n - 1) cout<<' ';
		else cout<<endl;
	}
}
```