#include using namespace std; using ll = long long; #define all(a) (a).begin(), (a).end() #define pb push_back #define fi first #define se second mt19937_64 rng(chrono::system_clock::now().time_since_epoch().count()); const ll MOD1000000007 = 1000000007; const ll MOD998244353 = 998244353; const ll MOD[3] = {999727999, 1070777777, 1000000007}; const ll LINF = 1LL << 60LL; const int IINF = (1 << 30) - 2; template struct edge{ int from; int to; T cost; int id; edge(){} edge(int to, T cost=1) : from(-1), to(to), cost(cost){} edge(int to, T cost, int id) : from(-1), to(to), cost(cost), id(id){} edge(int from, int to, T cost, int id) : from(from), to(to), cost(cost), id(id){} void reverse(){swap(from, to);} }; template struct edges : std::vector>{ void sort(){ std::sort( (*this).begin(), (*this).end(), [](const edge& a, const edge& b){ return a.cost < b.cost; } ); } }; template struct graph : std::vector>{ private: int n = 0; int m = 0; edges es; bool dir; public: graph(int n, bool dir) : n(n), dir(dir){ (*this).resize(n); } void add_edge(int from, int to, T cost=1){ if(dir){ es.push_back(edge(from, to, cost, m)); (*this)[from].push_back(edge(from, to, cost, m++)); }else{ if(from > to) swap(from, to); es.push_back(edge(from, to, cost, m)); (*this)[from].push_back(edge(from, to, cost, m)); (*this)[to].push_back(edge(to, from, cost, m++)); } } int get_vnum(){ return n; } int get_enum(){ return m; } bool get_dir(){ return dir; } edge get_edge(int i){ return es[i]; } edges get_edge_set(){ return es; } }; template struct redge{ int from, to; T cap, cost; int rev; redge(int to, T cap, T cost=(T)(1)) : from(-1), to(to), cap(cap), cost(cost){} redge(int to, T cap, T cost, int rev) : from(-1), to(to), cap(cap), cost(cost), rev(rev){} }; template using Edges = vector>; template using weighted_graph = vector>; template using tree = vector>; using unweighted_graph = vector>; template using residual_graph = vector>>; class shortest_path{ public: template static vector bfs(graph &G, int s){ int n = G.get_vnum(); vector dist(n, -1); dist[s] = 0; queue que; que.push(s); while(!que.empty()){ int v = que.front(); que.pop(); for(auto e : G[v]) if(dist[e.to]==-1){ dist[e.to] = dist[v] + 1; que.push(e.to); } } return dist; } template static vector binary_bfs(graph &G, int s){ int n = G.get_vnum(); vector dist(n, -1); dist[s] = 0; deque deq; deq.push_front(s); while(!deq.empty()){ int v = deq.front(); deq.pop_front(); for(auto e : G[v]) if(dist[e.to]==-1){ dist[e.to] = dist[v] + e.cost; if(e.cost) deq.push_back(e.to); else deq.push_front(e.to); } } return dist; } template static vector constant_bfs(graph &G, int s, T W){ int n = G.get_vnum(); vector dist(n, -1); vector> cand(n*W+1); dist[s] = 0; cand[0].push_back(s); for(int d=0; d<=n*W; d++) for(int v : cand[d]){ if(dist[v]!=-1) continue; for(auto e : G[v]) if(dist[v] + dist[e.to] < dist[e.ot]){ dist[e.to] = dist[v] + e.cost; cand[dist[e.to]].push_back(e.to); } } return dist; } template static vector complement_bfs(graph &G, int s){ int n = G.get_vnum(); map, bool> mp; for(int v=0; v dist(n, -1); vector unvisited; for(int v=0; v visited; visited.push(s); dist[s] = 0; while(!visited.empty()){ int v = visited.front(); visited.pop(); vector nxt; for(int to : unvisited){ if(!mp[{v, to}]){ visited.push(to); dist[to] = dist[v]+1; }else{ nxt.pb(to); } } unvisited = nxt; } return dist; } template static vector dijkstra(graph &G, int s){ int n = G.get_vnum(); const T TINF = numeric_limits::max()/2; vector dist(n, TINF); dist[s] = 0; priority_queue, vector>, greater<>> que; que.push({0, s}); while(!que.empty()){ auto [d, v] = que.top(); que.pop(); if(dist[v] < d) continue; for(auto e : G[v]){ if(dist[v] + e.cost < dist[e.to]){ dist[e.to] = dist[v] + e.cost; que.push({dist[e.to], e.to}); } } } for(int v=0; v static vector bellmanford(graph &G, int s){ int n = G.get_vnum(); bool dir = G.get_dir(); const T TINF = numeric_limits::max()/2; edges es = G.get_edge_set(); vector dist(n, TINF); vector flag(n, false); dist[s] = 0; for(int i=0; i static vector> warshall_floyd(graph &G){ int n = G.get_vnum(); const T TINF = numeric_limits::max()/2; vector> dist(n, vector(n, TINF)); for(int v=0; v static vector>> pered(graph &G, int k){ int n = G.get_vnum(); const T TINF = numeric_limits::max()/2; priority_queue, vector>, greater<>> que; vector>> neibors(n); vector> mp(n); for(int v=0; v // static T malick_mittal_gupta(graph &G, int s, int t){ // // declear variable // const T TINF = numeric_limits::max()/2; // dijkstra dijk_s(G, s), dijk_t(G, t); // int n = G.get_vnum(); // int m = G.get_enum(); // vector dist_s = dijk_s.get_dist(); // vector dist_t = dijk_t.get_dist(); // vector path = dijk_s.get_vpath(t); // int p = (int)path.size(); // path.push_back(n); // sentinel // vector> ch(n); // for(int v=0; v label(n, -1); // function labeling = [&](int v, int l){ // label[v] = l; // for(int to : ch[v]) dfs(to, l); // }; // for(int i=0; i> sevt(p), eevt(p); // for(int v=0; v label[y]) swap(x, y); // eset.insert({dist_s[x]+e.cost+dist_t[y], id}); // } // // calc ans // if(!eset.empty()) ans = min(ans, (*eset.begin()).first); // // end event with label = i // for(int id : evt[i]){ // auto e = G.get_edge(id); // int x = e.from, y = e.to; // if(label[x] > label[y]) swap(x, y); // eset.erase({dist_s[x]+e.cost+dist_t[y], id}); // } // } // return ans; // } template static vector yen(graph &G, int s, int t, int k){ } }; void solve(){ int n, m; cin >> n >> m; graph G(n, false); for(int i=0; i> u >> v; u--; v--; G.add_edge(u, v); } if((int)G[0].size()==0){ for(int i=1; i<=n; i++) cout << 0 << '\n'; return; } vector dist = shortest_path::bfs(G, 0); vector cnt(n+1, 0); for(int v=0; v sum(2, 0); sum[0] = cnt[0]; for(int i=1; i<=n; i++){ sum[i%2]+=cnt[i]; cout << sum[i%2] << '\n'; } } int main(){ cin.tie(nullptr); ios::sync_with_stdio(false); int T=1; //cin >> T; while(T--) solve(); }