#include <bits/stdc++.h>
using namespace std;
const int N = 10003;
vector<int> adj[N];
vector<int> enr[N];
int dep[N];
int par[N];
int ce[N];
int co[N];
bool q[N];
int cb = 0;
int bi;
void dfs(int u) {
  for (int i = 0; i < (int)adj[u].size(); ++i) {
    int v = adj[u][i];
    if (v == par[u]) continue;
    if (!dep[v]) {
      dep[v] = dep[u] + 1;
      par[v] = u;
      dfs(v);
      ce[u] += ce[v];
      co[u] += co[v];
    } else if (dep[u] < dep[v]) {
      if ((dep[u] - dep[v]) & 1)
        --ce[u];
      else
        --co[u];
    } else {
      if ((dep[u] - dep[v]) & 1)
        ++ce[u];
      else {
        ++co[u];
        ++cb;
        bi = enr[u][i];
      }
    }
  }
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; ++i) {
    int u, v;
    scanf("%d%d", &u, &v);
    adj[u].push_back(v);
    adj[v].push_back(u);
    enr[u].push_back(i);
    enr[v].push_back(i);
  }
  for (int u = 1; u <= n; ++u)
    if (!dep[u]) {
      dep[u] = 1;
      dfs(u);
    }
  if (cb == 0) {
    printf("%d\n", m);
    for (int i = 1; i <= m; ++i) {
      if (i > 1) printf(" ");
      printf("%d", i);
    }
    printf("\n");
  } else {
    if (cb == 1) q[bi] = true;
    for (int u = 1; u <= n; ++u) {
      for (int i = 0; i < (int)adj[u].size(); ++i) {
        int v = adj[u][i];
        if (u != par[v]) continue;
        if (co[v] == cb && ce[v] == 0) q[enr[u][i]] = true;
      }
    }
    vector<int> res;
    for (int i = 1; i <= m; ++i)
      if (q[i]) res.push_back(i);
    printf("%d\n", (int)res.size());
    for (int i = 0; i < (int)res.size(); ++i) {
      if (i > 0) printf(" ");
      printf("%d", res[i]);
    }
    printf("\n");
  }
  return 0;
}
