#include <bits/stdc++.h>
using namespace std;
int a, b, c, d, e, f, g, h, i, j, k;
int F[10005], G[10005];
vector<pair<int, int> > GG[10005];
vector<int> an;
int v[10005];
int father[10005];
int type[10005];
int cnt;
int er;
void soso(int x, int y) {
  int ii, jj, kk;
  type[x] = y;
  v[x] = 1;
  for (ii = 0; ii < GG[x].size(); ii++) {
    jj = GG[x][ii].first;
    if (GG[x][ii].second == father[x]) continue;
    if (v[jj] == 0) {
      father[jj] = GG[x][ii].second;
      soso(jj, y ^ 1);
      F[x] += F[jj];
      G[x] += G[jj];
    } else if (v[jj] == 1) {
      if (type[x] == type[jj]) {
        F[x]++;
        er = GG[x][ii].second;
        cnt++;
      } else
        G[x]++;
    } else {
      if (type[x] == type[jj])
        F[x]--;
      else
        G[x]--;
    }
  }
  v[x] = 2;
}
int main() {
  cin >> a >> b;
  for (i = 1; i <= b; i++) {
    scanf("%d%d", &c, &d);
    GG[c].push_back(make_pair(d, i));
    GG[d].push_back(make_pair(c, i));
  }
  for (i = 1; i <= a; i++)
    if (v[i] == 0) soso(i, 1);
  if (cnt == 0)
    for (i = 1; i <= b; i++) an.push_back(i);
  else {
    if (cnt == 1) an.push_back(er);
    for (i = 1; i <= a; i++)
      if (F[i] == cnt && G[i] == 0) an.push_back(father[i]);
  }
  sort(an.begin(), an.end());
  cout << an.size() << endl;
  for (i = 0; i < an.size(); i++) printf("%d ", an[i]);
  cout << endl;
  return 0;
}
