#include<bits/stdc++.h>
using namespace std;
long long n, m, e, h[1145141], ne[1145141], t[1145141], u, v, b[1145141], is[1145141], cnt, f[114514], d[1145141], cntt, cnttt;
struct AAA {
	int w, v;
} c[1145141];
map<long long, long long>ma;
int ct (int x, int y) {
	e++;
	ne[e] = h[x];
	h[x] = e;
	t[e] = y;
	return 0;
}
int dfs(int x, int y) {
	is[x] = 1;
	b[y]++;
	for (int i = h[x]; i; i = ne[i]) {
		if (!is[t[i]]) {
			dfs(t[i], y);
		}
	}
	return 0;
}
int main () {
	cin >> n >> m;
	for (int i = 1; i <= m; i++) {
		scanf("%lld %lld", &u, &v);
		ct(u, v);
		ct(v, u);
	}
	for (int i = 1; i <= n; i++) {
		if(!is[i]) {
			dfs(i, ++cnt);
		}
	}
	for (int j = 1; j <= n; j++) {
		f[j] = 11451419;
	}
	for (int i = 1; i <= cnt; i++) {
		if (!ma[b[i]])
			d[++cntt] = b[i];
		ma[b[i]]++;
	}
	for (int i = 1; i <= cntt; i++) {
		int blg = 1;
//		while (ma[d[i]]) {
//			if (ma[d[i]] & 1) {
//				c[++cnttt] = blg * d[i];
//			}
//			blg *= 2;
//			ma[d[i]] >>= 1;
//		}
		while (ma[d[i]] > blg) {
			ma[d[i]] -= blg;
			c[++cnttt].w = blg * d[i];
			c[++cnttt].v = blg;
			blg *= 2;
		}
		c[++cnttt].w = ma[d[i]] * d[i];
		c[++cnttt].v = ma[d[i]];
	}
	f[0] = 0;
	for (int i = 1; i <= cnttt; i++) {
		for (int j = n; j >= c[i].w; j--) {
			f[j] = min(f[j - c[i].w] + c[i].v, f[j]);
		}
		f[c[i].w] = 0;
	}
	for (int i = 1; i <= n; i++) {
		if (f[i] >= 11451419) cout << "-1\n";
		else
			cout << f[i] << "\n";
	}
}