#include <bits/stdc++.h>
using namespace std;
const int Inf = 0x3f3f3f3f;
const long long INF = 0x3f3f3f3f3f3f3f3fll;
int n, m;
vector<pair<int, int> > nei[10005];
bool lgl[10005];
int ceng[10005], col[10005], id[10005];
int fa[20][10005];
int f[10005], g[10005];
vector<int> nt, er, ans;
void inline predfs(int now, int lst, int lvl, int clr) {
  ceng[now] = lvl;
  col[now] = clr;
  lgl[now] = 1;
  for (__typeof((nei[now]).begin()) i = (nei[now]).begin(),
                                    _e_D_ = (nei[now]).end();
       i != _e_D_; i++)
    if (i->first != lst) {
      if (!lgl[i->first]) {
        predfs(i->first, now, lvl + 1, clr ^ 1);
        fa[0][i->first] = now;
        id[i->first] = i->second;
      } else if (now < i->first) {
        nt.push_back(i->second);
        if (col[now] == col[i->first]) er.push_back(i->second);
      }
    }
}
int inline lca(int a, int b) {
  if (ceng[a] > ceng[b]) swap(a, b);
  int toup = ceng[b] - ceng[a];
  for (int i = 0; i < (16); i++)
    if ((toup >> i) & 1) b = fa[i][b];
  if (a == b) return a;
  for (int i = (15); ((-1) > 0 ? i <= (0) : i >= (0)); i += (-1))
    if (fa[i][a] != fa[i][b]) a = fa[i][a], b = fa[i][b];
  return fa[0][a];
}
void inline dfs(int now, int lst) {
  lgl[now] = 1;
  for (__typeof((nei[now]).begin()) i = (nei[now]).begin(),
                                    _e_D_ = (nei[now]).end();
       i != _e_D_; i++)
    if (i->first != lst) {
      if (!lgl[i->first]) {
        dfs(i->first, now);
        f[now] += f[i->first];
        g[now] += g[i->first];
      } else {
        int fa = lca(now, i->first);
        if (col[now] == col[i->first])
          f[now]++, f[fa]--;
        else
          g[now]++, g[fa]--;
      }
    }
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= (m); i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    nei[u].push_back(make_pair(v, i));
    nei[v].push_back(make_pair(u, i));
  }
  for (int i = 1; i <= (n); i++)
    if (!lgl[i]) predfs(i, 0, 1, 0);
  if (!er.size())
    for (__typeof((nt).begin()) i = (nt).begin(), _e_D_ = (nt).end();
         i != _e_D_; i++)
      ans.push_back(*i);
  else if (er.size() == 1)
    ans.push_back(er[0]);
  for (int i = 1; i <= (15); i++)
    for (int j = 1; j <= (n); j++) fa[i][j] = fa[i - 1][fa[i - 1][j]];
  int ers = 0;
  for (int i = 1; i <= (n); i++)
    for (__typeof((nei[i]).begin()) j = (nei[i]).begin(),
                                    _e_D_ = (nei[i]).end();
         j != _e_D_; j++)
      if (col[i] == col[j->first]) ers++;
  ers >>= 1;
  memset(lgl, 0, sizeof(lgl));
  for (int i = 1; i <= (n); i++)
    if (!lgl[i]) dfs(i, 0);
  for (int i = 1; i <= (n); i++)
    if (id[i] && f[i] == ers && !(f[i] && g[i])) ans.push_back(id[i]);
  sort((ans).begin(), (ans).end());
  ans.erase(unique((ans).begin(), (ans).end()), ans.end());
  printf("%d\n", (int)ans.size());
  for (int i = 0; i < (ans.size()); i++)
    printf("%d%c", ans[i], " \n"[i == ans.size() - 1]);
  return 0;
}
