#include <bits/stdc++.h>
using namespace std;
vector<long long> v[10005];
long long lvl[10005], f, pa[10005], dp[10005][2];
bool vis[10005], b[10005];
pair<long long, long long> be;
map<pair<long long, long long>, long long> mp;
void dfs(long long x, long long l, long long p = -1) {
  vis[x] = 1;
  lvl[x] = l;
  pa[x] = p;
  if (l & 1) b[x] = 1;
  for (auto y : v[x]) {
    if (!vis[y]) {
      dfs(y, l + 1, x);
      dp[x][0] += dp[y][0];
      dp[x][1] += dp[y][1];
    } else if (y != p && lvl[y] < lvl[x]) {
      if ((lvl[x] & 1) == (lvl[y] & 1)) {
        f++;
        if (f == 1) {
          long long tx = x, ty = y;
          if (tx > ty) swap(tx, ty);
          be = {tx, ty};
        }
        dp[x][0]++;
      } else
        dp[x][1]++;
    } else if (y != p) {
      if ((lvl[x] & 1) == (lvl[y] & 1))
        dp[x][0]--;
      else
        dp[x][1]--;
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n, m;
  cin >> n >> m;
  for (long long i = 0; i < m; i++) {
    long long x, y;
    cin >> x >> y;
    v[x].push_back(y);
    v[y].push_back(x);
    if (x > y) swap(x, y);
    mp[{x, y}] = i + 1;
  }
  for (long long i = 1; i <= n; i++)
    if (!vis[i]) dfs(i, 0);
  if (f == 0) {
    cout << m << '\n';
    for (long long i = 1; i <= m; i++) cout << i << ' ';
    cout << '\n';
    return 0;
  }
  vector<long long> ans;
  if (f == 1) {
    ans.push_back(mp[be]);
  }
  for (long long i = 2; i <= n; i++) {
    if (dp[i][0] == f && dp[i][1] == 0) {
      long long tx = i, ty = pa[i];
      if (tx > ty) swap(tx, ty);
      ans.push_back(mp[{tx, ty}]);
    }
  }
  sort(ans.begin(), ans.end());
  cout << ans.size() << '\n';
  for (auto i : ans) cout << i << ' ';
  cout << '\n';
}
