#include using namespace std; typedef long long ll; typedef vector vi; typedef vector vl; typedef complex P; typedef pair pii; #define REP(i,n) for(ll i=0;i> n >> m; UF uf(n); REP(i,m){ int u,v; cin>>u>>v; --u;--v; uf.unite(u,v); } map szs; REP(i,n){ if(uf.root(i)==i) szs[uf.size(i)]+=1; // szs.push_back(uf.size(i)); } map dp; map::iterator iter; // vl dp(n+1,1e18); dp[0] = -1; map::iterator iter2; iter2 = szs.begin(); while(iter2!=szs.end()){ ll num = iter2->first; ll cnt = iter2->second; ++iter2; iter = dp.end(); while(iter!=dp.begin()){ // REPR(_j,n+1){ // ll id = n-_j; // ll val = dp[id]; --iter; ll id = iter->first; ll val = iter->second; REP(i,cnt){ id += num; val += 1; if(id>n)break; if(dp.count(id)){ dp[id]=min(dp[id],val); }else{ dp[id]=val; } } // if(id+szs[i]<=n){ // if(dp.count(id+szs[i]) == 1) // dp[id+szs[i]] = min(dp[id+szs[i]],val+1); // else // dp[id+szs[i]] = val+1; // } } } REPR(i,n+1){ if(dp.count(i) == 1){ // if(dp[i]!=1e18){ cout << dp[i] << endl; }else{ cout << -1 << endl; } } return 0; }