#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e4 + 5;
template <typename T>
inline void read(T& x) {
  x = 0;
  char temp = getchar();
  bool f = false;
  while (!isdigit(temp)) {
    if (temp == '-') f = true;
    temp = getchar();
  }
  while (isdigit(temp)) {
    x = (x << 1) + (x << 3) + temp - '0';
    temp = getchar();
  }
  if (f) x = -x;
}
template <typename T>
void print(T x) {
  if (x < 0) putchar('-'), x = -x;
  if (x > 9) print(x / 10);
  putchar(x % 10 + '0');
}
int n, m;
int u[MAXN], v[MAXN];
struct node {
  int to, next;
} edge[MAXN << 1];
int head[MAXN], cnt = 1;
inline void AddEdge(int u, int v) {
  edge[++cnt] = (node){v, head[u]}, head[u] = cnt;
}
void Add(int u, int v) { AddEdge(u, v), AddEdge(v, u); }
bool vis[MAXN], intree[MAXN];
int ancestor[MAXN][16], depth[MAXN];
void Dfs(int id, int fa) {
  ancestor[id][0] = fa;
  depth[id] = depth[fa] + 1;
  for (register int i = 0; i < 15; i++)
    ancestor[id][i + 1] = ancestor[ancestor[id][i]][i];
  vis[id] = true;
  for (register int i = head[id]; i; i = edge[i].next) {
    int son = edge[i].to;
    if (!vis[son]) intree[i >> 1] = true, Dfs(son, id);
  }
}
inline int LCA(int id1, int id2) {
  if (depth[id1] < depth[id2]) swap(id1, id2);
  for (register int i = 15; i >= 0; i--) {
    if (depth[ancestor[id1][i]] >= depth[id2]) id1 = ancestor[id1][i];
    if (id1 == id2) return id1;
  }
  for (register int i = 15; i >= 0; i--)
    if (ancestor[id1][i] != ancestor[id2][i])
      id1 = ancestor[id1][i], id2 = ancestor[id2][i];
  return ancestor[id1][0];
}
int odd;
int ans[MAXN], mark[MAXN], tot;
inline void Mark(int x, int y, int lca, int val) {
  mark[x] += val, mark[y] += val, mark[lca] -= 2 * val;
}
void Getans(int id, int tar, int last) {
  vis[id] = true;
  for (register int i = head[id]; i; i = edge[i].next) {
    int son = edge[i].to;
    if (!vis[son] && intree[i >> 1])
      Getans(son, tar, i >> 1), mark[id] += mark[son];
  }
  if (mark[id] == tar) ans[++tot] = last;
}
inline void Solve() {
  int temp = 0;
  for (register int i = 1; i <= m; i++)
    if (!intree[i]) {
      int x = u[i], y = v[i], lca = LCA(x, y),
          len = depth[x] + depth[y] - depth[lca] * 2 + 1;
      if (len & 1)
        odd++, temp = i, Mark(x, y, lca, 1);
      else
        Mark(x, y, lca, -1);
    }
  if (odd == 0) {
    print(m), puts("");
    for (register int i = 1; i <= m; i++) print(i), putchar(' ');
    return;
  }
  memset(vis, false, sizeof(vis));
  for (register int i = 1; i <= n; i++)
    if (!vis[i]) Getans(i, odd, 0);
  if (odd == 1) ans[++tot] = temp;
  print(tot), puts("");
  sort(ans + 1, ans + 1 + tot);
  for (register int i = 1; i <= tot; i++) print(ans[i]), putchar(' ');
}
int main() {
  read(n), read(m);
  for (register int i = 1; i <= m; i++) read(u[i]), read(v[i]), Add(u[i], v[i]);
  for (register int i = 1; i <= n; i++)
    if (!vis[i]) Dfs(i, 0);
  Solve();
  return 0;
}
