#include <bits/stdc++.h>
using namespace std;

struct UnionFind {
    vector<long long> data;

    UnionFind(long long N) : data(vector<long long>(N, -1)) {}

    long long root(long long x) {
        if (data[x] < 0) {
            return x;
        } else {
            return data[x] = root(data[x]);
        }
    }

    bool same(long long x, long long y) {
        return root(x) == root(y);
    }

    void unite(long long x, long long y) {
        if (!same(x, y)) {
            x = root(x);
            y = root(y);
            if (data[x] < data[y]) {
                data[x] += data[y];
                data[y] = x;
            } else {
                data[y] += data[x];
                data[x] = y;
            }
        }
        return;
    }
};

int bfs(int x, int n, vector<vector<int>>& adj) {
    int N = adj.size();
    int dist[N] = {};
    for (int i = 0; i < N; i++) {
        dist[i] = -1;
    }
    dist[x] = n;
    queue<int> que;
    que.push(x);
    while (que.size()) {
        int tmp = que.front();
        que.pop();
        for (auto a : adj[tmp]) {
            if (dist[a] == -1) {
                que.push(a);
                dist[a] = (dist[tmp] + 1) % 2;
            }
        }
    }
    for (int i = 0; i < adj.size(); i++) {
        for (auto a : adj[i]) {
            if (dist[i] != -1 && dist[a] != -1) {
                if (dist[i] == dist[a]) {
                    return -1;
                }
            }
        }
    }
    int res = 0;
    for (auto a : dist) {
        if (a == 1) {
            res += a;
        }
    }
    return res;
}

void solve(int& N, int& M) {
    UnionFind UF(N);
    vector<vector<int>> adj(N);
    for (int i = 0; i < M; i++) {
        int u, v;
        cin >> u >> v;
        u--;
        v--;
        adj[u].push_back(v);
        adj[v].push_back(u);
        UF.unite(u, v);
    }
    set<int> parent;
    for (int i = 0; i < N; i++) {
        parent.insert(UF.root(i));
    }
    map<int, set<int>> cnt;
    for (int i = 0; i < N; i++) {
        int tmp1 = bfs(i, 0, adj);
        int tmp2 = bfs(i, 1, adj);
        if (tmp1 != -1 && tmp1 % 2 == 0) {
            cnt[UF.root(i)].insert(tmp1 / 2);
        }
        if (tmp2 != -1 && tmp2 % 2 == 0) {
            cnt[UF.root(i)].insert(tmp2 / 2);
        }
    }
    int idx = 0;
    vector<int> ans;
    vector<vector<int>> v(parent.size());
    for (auto P : parent) {
        for (auto X : cnt[P]) {
            v[idx].push_back(X);
        }
        idx += 1;
    }
    for (int i = 0; i < v[0].size(); i++) {
        ans.push_back(v[0][i]);
    }
    for (int i = 1; i < v.size(); i++) {
        set<int> tmp;
        for (int j = 0; j < v[i].size(); j++) {
            for (auto X : ans) {
                tmp.insert(X + v[i][j]);
            }
        }
        while (ans.size()) {
            ans.pop_back();
        }
        for (auto X : tmp) {
            ans.push_back(X);
        }
    }
    cout << ans.size() << endl;
    for (auto X : ans) {
        cout << X << endl;
    }
}

int main() {
    int N, M;
    while (true) {
        cin >> N >> M;
        if (!N && !M) {
            return 0;
        }
        solve(N, M);
    }
}


Measured memory_bytes: 3236