#include <bits/stdc++.h>
using namespace std;
const int mxn = 10010;
int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
struct Edge {
  int u, v;
  int o, e;
} eg[mxn];
int cnt = 0;
struct edge {
  int v, nxt;
  int id;
} e[mxn << 1];
int hd[mxn], mct = 0;
void add_edge(int u, int v, int id) {
  e[++mct].v = v;
  e[mct].id = id;
  e[mct].nxt = hd[u];
  hd[u] = mct;
  return;
}
int n, m, ans;
int ansedge[mxn];
int dep[mxn];
bool vis[mxn];
void DFS(int u, int deep) {
  dep[u] = deep;
  for (int i = hd[u]; i; i = e[i].nxt) {
    int v = e[i].v;
    if (!dep[v]) {
      vis[e[i].id] = 1;
      DFS(v, deep + 1);
    }
  }
  return;
}
int Oct[mxn], ect[mxn];
int gct = 0;
void solve() {
  int i, j;
  gct = 0;
  for (i = 1; i <= m; i++) {
    if (!vis[i]) {
      int u = eg[i].u;
      int v = eg[i].v;
      if (dep[u] > dep[v]) swap(u, v);
      if ((dep[v] - dep[u]) % 2 == 0) {
        Oct[u]--;
        Oct[v]++;
        eg[i].o = 1;
        gct++;
      } else {
        ect[u]--;
        ect[v]++;
      }
    }
  }
  return;
}
void getsum(int u) {
  dep[u] = 1;
  for (int j = hd[u]; j; j = e[j].nxt) {
    int v = e[j].v;
    if (!vis[e[j].id] || dep[v]) continue;
    getsum(v);
    Oct[u] += Oct[v];
    ect[u] += ect[v];
    eg[e[j].id].o = Oct[v];
    eg[e[j].id].e = ect[v];
  }
  return;
}
int main() {
  n = read();
  m = read();
  int i, j, u, v;
  for (i = 1; i <= m; i++) {
    eg[i].u = read();
    eg[i].v = read();
    add_edge(eg[i].u, eg[i].v, i);
    add_edge(eg[i].v, eg[i].u, i);
  }
  for (i = 1; i <= n; i++)
    if (!dep[i]) DFS(i, 1);
  solve();
  if (!gct) {
    printf("%d\n", m);
    for (i = 1; i <= m; i++) printf("%d ", i);
    return 0;
  }
  memset(dep, 0, sizeof dep);
  for (i = 1; i <= n; i++)
    if (!dep[i]) getsum(i);
  for (i = 1; i <= m; i++) {
    if (!vis[i]) {
      if (gct == 1 && eg[i].o) ansedge[++ans] = i;
    } else if (eg[i].o == gct && !eg[i].e) {
      ansedge[++ans] = i;
    }
  }
  printf("%d\n", ans);
  for (i = 1; i <= ans; i++) printf("%d ", ansedge[i]);
  return 0;
}
