#include <bits/stdc++.h>
using namespace std;
int n, m;
struct ENode {
  int v;
  int id;
  ENode *next;
};
typedef ENode *elist;
elist de[10000];
void AddEdge(int u, int v, int id) {
  elist l = new ENode;
  l->next = de[u];
  de[u] = l;
  l->id = id;
  l->v = v;
}
int state[10000];
int color[10000];
int v2e[10000];
int sumOdd[10000], sumEven[10000];
int countOdd, oneOddEdge;
void DFS(int u, int fa) {
  state[u] = 1;
  for (elist l = de[u]; l; l = l->next)
    if (l->v != fa) {
      int v = l->v;
      if (state[v] == 0) {
        v2e[v] = l->id;
        color[v] = 1 - color[u];
        DFS(v, u);
        sumOdd[u] += sumOdd[v];
        sumEven[u] += sumEven[v];
      } else if (state[v] == 1) {
        if (color[v] == color[u]) {
          sumOdd[u]++, oneOddEdge = l->id, countOdd++;
          sumOdd[v]--;
        } else {
          sumEven[v]++;
          sumEven[u]--;
        }
      }
    }
  state[u] = 2;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    u--;
    v--;
    AddEdge(u, v, i);
    AddEdge(v, u, i);
  }
  vector<int> ans;
  memset(state, 0, sizeof(state));
  for (int i = 0; i < n; i++) {
    if (state[i] == 0) {
      color[i] = 0;
      DFS(i, -1);
    }
  }
  if (countOdd == 0)
    for (int i = 0; i < m; i++) ans.push_back(i);
  else {
    if (countOdd == 1) ans.push_back(oneOddEdge);
    for (int i = 0; i < n; i++) {
      if (sumOdd[i] == countOdd && sumEven[i] == 0) ans.push_back(v2e[i]);
    }
  }
  sort(ans.begin(), ans.end());
  printf("%d\n", (int)ans.size());
  for (int i = 0; i < (int)ans.size(); i++) printf("%d ", ans[i] + 1);
  printf("\n");
  return 0;
}
