// https://oj.uz/problem/view/EGOI23_ppp
#include<iostream>
#include<vector>
using namespace std;
typedef pair<int,int> pii;
const int mx = 2e5+10;
vector<int> ans(mx ,0);
vector<vector<int>> g(mx);
vector<pii> event(mx);
vector<int> match(mx, -1), p(mx, -1), cnt(mx, 0);
void dfs(int now, int pre, int MAXN, int MAX) {
for(int i: g[now]) {
cout<<now<<' '<<i<<'\n';
int win = event[i].first;
cnt[win] += (now - i); // 持有天數+1
int mxn = MAXN, mx = MAX;
if(cnt[win] > mxn) {mxn = cnt[win]; mx = win;}
else if(cnt[win] == mxn) mx = min(mx, win);
ans[mx]++;
dfs(i, now, mxn, mx);
cnt[win] -= (now - i);
}
}
int main() {
// ios::sync_with_stdio(false);
// cin.tie(0);
int N, M;
cin>>N>>M;
for(int i=1; i<=M; i++) {
int win, lose;
cin>>win>>lose;
event[i].first = win;
event[i].second = lose;
if(match[win]!=-1) {g[i].push_back(match[win]); p[match[win]] = i;}
if(match[lose]!=-1) {g[i].push_back(match[lose]); p[match[lose]] = i;}
match[win] = i;
match[lose] = -1;
}
for(int i=1; i<=M; i++)
if(p[i] == -1) g[M+1].push_back(i); // fake node
dfs(M+1, M+1, 0, N+1);
for(int i=0; i<N; i++) cout<<ans[i]<<' ';
}