#include <bits/stdc++.h>
using namespace std;
const int maxn = 10000 + 2;
struct Tedge {
  int v, next, inx;
} e[maxn * 2];
int N;
int head[maxn];
void insert(int x, int y, int inx) {
  e[N].v = y;
  e[N].inx = inx;
  e[N].next = head[x];
  head[x] = N;
  N++;
}
int last, cnt, times;
int odd[maxn], even[maxn], inx[maxn], dfn[maxn];
void dfs(int u, int pre) {
  dfn[u] = ++times;
  inx[u] = inx[pre] ^ 1;
  for (int i = head[u]; i != -1; i = e[i].next)
    if (e[i].v != pre) {
      if (!dfn[e[i].v])
        dfs(e[i].v, u);
      else if (dfn[e[i].v] < dfn[u]) {
        if (!(inx[e[i].v] ^ inx[u])) {
          odd[u]++;
          odd[e[i].v]--;
          cnt++;
          last = e[i].inx;
        } else {
          even[u]++;
          even[e[i].v]--;
        }
      }
    }
}
bool ans[maxn], vis[maxn];
void get(int u, int pre, int &od, int &ev) {
  int oo = 0, ee = 0;
  vis[u] = true;
  for (int i = head[u]; i != -1; i = e[i].next)
    if (!vis[e[i].v]) {
      get(e[i].v, u, oo, ee);
      if (cnt && oo == cnt && !ee) ans[e[i].inx] = true;
      od += oo;
      ev += ee;
      oo = 0;
      ee = 0;
    }
  od += odd[u];
  ev += even[u];
}
int n, m;
int main() {
  int a, b;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) head[i] = -1;
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &a, &b);
    insert(a, b, i);
    insert(b, a, i);
  }
  int c = 0;
  for (int i = 1; i <= n; i++) {
    if (dfn[i]) continue;
    times = 0;
    cnt = 0;
    dfs(i, 0);
    get(i, 0, a, b);
    if (cnt == 0) continue;
    c++;
    if (cnt == 1) ans[last] = true;
  }
  if (c == 0) {
    printf("%d\n", m);
    for (int i = 1; i <= m; i++) printf("%d ", i);
    if (m) printf("\n");
    return 0;
  }
  if (c > 1) {
    printf("0\n");
    return 0;
  }
  cnt = 0;
  for (int i = 1; i <= m; i++)
    if (ans[i]) cnt++;
  printf("%d\n", cnt);
  for (int i = 1; i <= m; i++)
    if (ans[i]) printf("%d ", i);
  return 0;
}
