#include "bits/stdc++.h" using namespace std; #define all(x) x.begin(),x.end() template ostream& operator<<(ostream &os, const pair &p) { return os << p.first << " " << p.second; } template::value, typename T_container::value_type>::type> ostream& operator<<(ostream &os, const T_container &v) { string sep; for (const T &x : v) os << sep << x, sep = " "; return os; } #ifdef LOCAL #include "debug.h" #else #define debug(...) 42 #define ASSERT(...) 42 #endif typedef long long ll; typedef vector vi; typedef vector vvi; typedef pair pi; const int oo = 1e9; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n,m; cin >> n >> m; vector> es(m); vector> adj(n); for(auto& [u,v,w] : es) { cin >> u >> v; w=1; --u,--v; adj[u].push_back({v,w}); adj[v].push_back({u,w}); } auto dijkstra = [&](int s) { vector d(n,oo); struct el { int at; ll d; bool operator<(const el& e) const { return d>e.d; } }; priority_queue pq; auto push = [&](int at, ll dd) { if(d[at]>dd) { pq.push({at,dd}); d[at]=dd; } }; push(s,0); while(!pq.empty()) { auto e = pq.top(); pq.pop(); if(e.d!=d[e.at]) continue; for(auto [to,w] : adj[e.at]) { push(to,w+e.d); } } return d; }; auto d = dijkstra(0); vi ans(n); vi cnt(n+1); for(auto& i : d) if(i=2) cnt[i]+=cnt[i-2]; } cnt.erase(cnt.begin()); for(auto x : cnt) cout << x << '\n'; }