#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void checkmin(T &a, const T &b) {
  if (b < a) a = b;
}
template <class T>
inline void checkmax(T &a, const T &b) {
  if (b > a) a = b;
}
const int inf = 1e9 + 10;
const int maxn = 1e4 + 10;
vector<pair<int, int> > g[maxn], e;
int vis[maxn], col[maxn], odd_edge, odd_cycle = 0;
int odd[maxn], even[maxn], edge[maxn];
int n, m;
void dfs(int x, int fa, int c) {
  vis[x] = 1;
  col[x] = c;
  for (int i = 0; i < g[x].size(); i++) {
    int to = g[x][i].first, id = g[x][i].second;
    if (to == fa) continue;
    if (vis[to] == 0) {
      edge[to] = id;
      dfs(to, x, c ^ 1);
      odd[x] += odd[to];
      even[x] += even[to];
    } else if (vis[to] == 1) {
      if (col[to] == c) {
        odd[x]++;
        odd_cycle++;
        odd_edge = id;
      } else
        even[x]++;
    } else {
      if (col[to] == c)
        odd[x]--;
      else
        even[x]--;
    }
  }
  vis[x] = 2;
}
int main() {
  for (int i = 0; i < maxn; i++) col[i] = -1;
  for (int i = 0; i < maxn; i++) edge[i] = -1;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    u--;
    v--;
    g[u].push_back(make_pair(v, i));
    g[v].push_back(make_pair(u, i));
    e.push_back(make_pair(u, v));
  }
  for (int i = 0; i < n; i++)
    if (!vis[i]) dfs(i, -1, 0);
  if (odd_cycle == 0) {
    cout << m << endl;
    for (int i = 1; i <= m; i++) cout << i << " ";
    cout << endl;
    return 0;
  } else {
    vector<int> ans;
    if (odd_cycle == 1) ans.push_back(odd_edge);
    for (int i = 0; i < n; i++) {
      if (edge[i] >= 0 && odd[i] == odd_cycle && even[i] == 0) {
        ans.push_back(edge[i]);
      }
    }
    cout << ans.size() << endl;
    sort(ans.begin(), ans.end());
    for (int i = 0; i < ans.size(); i++) cout << ans[i] + 1 << " ";
    cout << endl;
  }
  return 0;
}
