#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const long long LINF = 2e16;
const int INF = 2e9;
const int magic = 348;
const double eps = 1e-10;
const double pi = 3.14159265;
inline int getint() {
  char ch;
  int res;
  bool f;
  while (!isdigit(ch = getchar()) && ch != '-') {
  }
  if (ch == '-')
    f = false, res = 0;
  else
    f = true, res = ch - '0';
  while (isdigit(ch = getchar())) res = res * 10 + ch - '0';
  return f ? res : -res;
}
int n, e;
int ansnum;
vector<int> ans;
vector<pair<int, int> > v[10048];
int dfn[10048], low[10048], ind;
int depth[10048], fa[10048], fa_ind[10048];
bool iseven[10048];
int anc[10048][21];
struct Edge {
  int first, second;
  int ind;
};
vector<Edge> tedge, ntedge;
pair<int, int> edge[10048];
void Tarjan(int cur) {
  dfn[cur] = low[cur] = ++ind;
  int i, j, to;
  for (i = 0; i < int(v[cur].size()); i++) {
    to = v[cur][i].first;
    if (!dfn[to]) {
      fa[to] = cur;
      fa_ind[to] = v[cur][i].second;
      depth[to] = depth[cur] + 1;
      tedge.push_back(Edge{cur, to, v[cur][i].second});
      anc[to][0] = cur;
      for (j = 1; j <= 20; j++) anc[to][j] = anc[anc[to][j - 1]][j - 1];
      Tarjan(to);
      low[cur] = min(low[cur], low[to]);
    } else {
      if (to != fa[cur] && depth[cur] > depth[to] &&
          (depth[cur] - depth[to]) & 1)
        low[cur] = min(low[cur], dfn[to]);
      if (to != fa[cur] && depth[cur] > depth[to] &&
          !((depth[cur] - depth[to]) & 1))
        ntedge.push_back(Edge{to, cur, v[cur][i].second});
    }
  }
}
int lca(int u, int v) {
  if (depth[u] < depth[v]) swap(u, v);
  int i;
  for (i = 20; i >= 0; i--)
    if (depth[anc[u][i]] >= depth[v]) u = anc[u][i];
  if (u == v) return u;
  for (i = 20; i >= 0; i--)
    if (anc[u][i] != anc[v][i]) {
      u = anc[u][i];
      v = anc[v][i];
    }
  return anc[u][0];
}
int Low(int u, int v) {
  if (depth[u] < depth[v]) swap(u, v);
  int LCA = lca(u, v);
  if (LCA != u && LCA != v) return -1;
  return u;
}
bool isanc(int u, int v) {
  if (u == v) return false;
  return lca(u, v) == u;
}
int main() {
  int i, cur, first, second;
  n = getint();
  e = getint();
  for (i = 1; i <= e; i++) {
    first = getint();
    second = getint();
    edge[i] = make_pair(first, second);
    v[first].push_back(make_pair(second, i));
    v[second].push_back(make_pair(first, i));
  }
  int all_cnt = 0, superf = true;
  for (cur = 1; cur <= n; cur++)
    if (!dfn[cur]) {
      tedge.clear();
      ntedge.clear();
      fa[cur] = 0;
      ind = 0;
      depth[cur] = 1;
      Tarjan(cur);
      for (i = 0; i < int(tedge.size()); i++) {
        if (depth[tedge[i].first] > depth[tedge[i].second])
          swap(edge[i].first, edge[i].second);
        if (low[tedge[i].second] != dfn[tedge[i].second])
          iseven[tedge[i].ind] = true;
      }
      if (int(ntedge.size())) all_cnt++;
      if (int(ntedge.size()) == 1) {
        ansnum++;
        ans.push_back(ntedge[0].ind);
      }
      int curu = -2, curv = -2;
      for (i = 0; i < int(ntedge.size()); i++) {
        if (depth[ntedge[i].first] > depth[ntedge[i].second])
          swap(ntedge[i].first, ntedge[i].second);
        if (curu == -2) {
          curu = ntedge[i].first;
          curv = ntedge[i].second;
          continue;
        }
        curu = Low(ntedge[i].first, curu);
        if (curu == -1) {
          superf = false;
          break;
        }
        curv = lca(ntedge[i].second, curv);
        if (!isanc(curu, curv)) {
          superf = false;
          break;
        }
      }
      if (!superf) break;
      for (; curv != curu; curv = fa[curv])
        if (!iseven[fa_ind[curv]]) {
          ansnum++;
          ans.push_back(fa_ind[curv]);
        }
    }
  if (!superf) {
    printf("0\n");
    return 0;
  }
  if (all_cnt == 0) {
    printf("%d\n", e);
    for (i = 1; i <= e; i++) printf("%d ", i);
    printf("\n");
    return 0;
  }
  if (all_cnt > 1) {
    printf("0\n");
    return 0;
  }
  printf("%d\n", ansnum);
  if (ansnum) {
    sort(ans.begin(), ans.end());
    for (i = 0; i < int(ans.size()); i++) printf("%d ", ans[i]);
    printf("\n");
  }
  return 0;
}
