2 0
 100000 0
 8 9
1 2
2 3
3 4
4 1
5 6
6 7
7 8
8 5
6 8
 2 1
1 2
 11 9
5 9
8 5
11 3
11 1
3 4
7 11
3 1
11 2
7 2
 7 9
7 3
7 4
1 2
2 3
3 1
3 4
4 5
5 6
6 4
 7 5
5 4
7 3
7 1
6 7
3 1
 7 8
1 2
2 3
3 4
4 1
3 5
5 6
6 7
7 3
 6 9
1 2
2 3
1 4
4 2
5 2
5 3
4 5
6 4
6 5
 7 9
1 2
2 4
4 3
3 1
2 3
4 5
5 6
6 7
7 4
 1 0
 6 7
1 2
2 3
3 1
3 4
4 5
5 6
6 4
 4 5
1 2
2 3
3 4
4 1
1 3
 100000 3
99998 99999
99999 100000
100000 99998

0

 0

 4
1 2 3 4 
 0

 6
3 4 6 7 8 9 
 9
1 2 3 4 5 6 7 8 9 
 3
2 3 5 
 8
1 2 3 4 5 6 7 8 
 0

 4
6 7 8 9 
 0

 6
1 2 3 5 6 7 
 0

 3
1 2 3 

#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int low[N], dep[N], p[N], t = 0;
stack<int> s;
bitset<N> went, in, used;
vector<pair<int, int> > graph[N];
void dfs(int now) {
  low[now] = dep[now] = ++t;
  went[now] = in[now] = true;
  s.push(now);
  for (pair<int, int> i : graph[now]) {
    if (!went[i.first]) {
      used[i.second] = true;
      dfs(i.first);
      if (in[i.first]) low[now] = min(low[now], low[i.first]);
    }
    if (in[i.first] && !used[i.second]) low[now] = min(low[now], low[i.first]);
  }
  if (low[now] == dep[now]) {
    while (s.top() != now) {
      in[s.top()] = false;
      p[s.top()] = now;
      s.pop();
    }
    in[now] = false;
    p[now] = now;
    s.pop();
  }
  return;
}
int main() {
  int n, m, l, r;
  bool f;
  vector<int> ans, g[N];
  vector<pair<int, int> > ng[N];
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &l, &r);
    graph[l].push_back({r, i});
    graph[r].push_back({l, i});
  }
  used.reset();
  went.reset();
  in.reset();
  for (int i = 1; i <= n; i++)
    if (!went[i]) dfs(i);
  for (int i = 1; i <= n; i++)
    for (pair<int, int> j : graph[i])
      if (p[j.first] == p[i]) {
        g[p[i]].push_back(j.first);
        ng[j.first].push_back({i, j.second});
        ng[i].push_back(j);
      }
  for (int i = 1; i <= n; i++) {
    f = true;
    for (int j : g[i])
      if (ng[j].size() != 4) {
        f = false;
        break;
      }
    if (f)
      for (int j : g[i])
        for (pair<int, int> k : ng[j]) ans.push_back(k.second);
  }
  if (ans.empty())
    printf("0\n\n");
  else {
    sort(ans.begin(), ans.end());
    ans.resize(unique(ans.begin(), ans.end()) - ans.begin());
    printf("%ld\n%d", ans.size(), ans[0]);
    for (int i = 1; i < ans.size(); i++) printf(" %d", ans[i]);
    printf("\n");
  }
}
