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;
char string_in_buffer[(int)260];
void fast_scan(int &first) { scanf("%d", &first); }
void fast_scan(long long &first) { scanf("%lld", &first); }
void fast_scan(unsigned long long &first) { scanf("%llu", &first); }
void fast_scan(double &first) { scanf("%lf", &first); }
void fast_scan(long double &first) { scanf("%Lf", &first); }
void fast_scan(char &first) {
  scanf("%c", &first);
  if (first == '\n') {
    fast_scan(first);
  }
}
void fast_scan(string &first) {
  scanf("%s", string_in_buffer);
  first = string(string_in_buffer);
}
template <class TFirst, class TSecond>
void fast_scan(pair<TFirst, TSecond> &p) {
  fast_scan(p.first);
  fast_scan(p.second);
}
template <class T>
void fast_scan(vector<T> &v) {
  for (auto &first : v) fast_scan(first);
}
void fast_print(const int &first) { printf("%d", first); }
void fast_print(const long long &first) { printf("%lld", first); }
void fast_print(const unsigned long long &first) { printf("%llu", first); }
void fast_print(const double &first) { printf("%.15lf", first); }
void fast_print(const long double &first) { printf("%.15Lf", first); }
void fast_print(const char &first) { printf("%c", first); };
void fast_print(const string &first) { printf("%s", first.c_str()); }
void fast_print(const char v[]) { fast_print((string)v); }
template <class TFirst, class TSecond>
void fast_print(const pair<TFirst, TSecond> &p) {
  fast_print(p.first);
  fast_print(' ');
  fast_print(p.second);
}
template <class T>
void fast_print(const vector<T> &v) {
  if (v.empty()) return;
  fast_print(v[0]);
  for (int i = 1; i < v.size(); i++) {
    fast_print(' ');
    fast_print(v[i]);
  }
}
template <class T>
void fast_print(const vector<vector<T>> &v) {
  if (v.empty()) return;
  fast_print(v[0]);
  for (int i = 1; i < v.size(); i++) {
    fast_print('\n');
    fast_print(v[i]);
  }
}
template <class T>
void fast_print(const T &v) {
  for (const auto &first : v) {
    fast_print(first);
    fast_print(' ');
  }
}
using namespace std;
namespace smart_io {
string print_start = "";
string sep = " ";
bool first_print = false;
void precall_print() {
  fast_print(print_start);
  print_start = "\n";
  first_print = true;
}
void _print(deque<string>) {}
template <class T, class... Args>
void _print(deque<string> names, T kek, Args... args) {
  if (!first_print) {
    fast_print("\n");
  } else {
    first_print = false;
  }
  fast_print(names.front());
  fast_print(" = ");
  fast_print(kek);
  names.pop_front();
  _print(names, args...);
}
}  // namespace smart_io
template <class T>
ostream &operator,(ostream &os, const T &object) {
  if (!smart_io::first_print) {
    fast_print(smart_io::sep);
  } else {
    smart_io::first_print = false;
  }
  fast_print(object);
  return os;
}
template <class T>
istream &operator,(istream &is, T &object) {
  fast_scan(object);
  return is;
}
namespace typedefs {}
namespace numbers_operation {
template <class T>
T floor_mod(T a, T b) {
  if (a % b == 0) return 0;
  if (a >= 0 && b >= 0) return a % b;
  if (a <= 0 && b <= 0) return a % b;
  return abs(b) - (abs(a) % abs(b));
}
}  // namespace numbers_operation
using namespace numbers_operation;
using namespace typedefs;
int n, m;
vector<vector<int>> g;
vector<int> tin, uptime;
vector<bool> used;
int timer = 0;
map<pair<int, int>, int> id;
void dfs_time(int v) {
  tin[v] = timer++;
  used[v] = true;
  for (int sub : g[v]) {
    if (used[sub]) continue;
    dfs_time(sub);
  }
}
set<pair<int, int>> bridges;
void dfs(int v, int _p) {
  used[v] = true;
  uptime[v] = tin[v];
  for (int sub : g[v]) {
    if (sub == _p) continue;
    if (!used[sub]) {
      dfs(sub, v);
    }
    if (tin[v] < uptime[sub]) {
      bridges.emplace(v, sub);
      bridges.emplace(sub, v);
    }
    uptime[v] = min(uptime[v], uptime[sub]);
  }
}
vector<int> comp;
vector<pair<int, int>> edges;
void dfs_comp(int v) {
  used[v] = true;
  comp.push_back(v);
  for (int sub : g[v]) {
    if (bridges.count(make_pair(v, sub))) continue;
    edges.emplace_back(v, sub);
    if (used[sub]) continue;
    dfs_comp(sub);
  }
}
signed main(signed argc, char *argv[]) {
  {
    cin, n, m;
    g.resize(n);
  }
  {
    for (int i = 0; i < (m); i++) {
      int a, b;
      cin, a, b;
      a--;
      b--;
      g[a].push_back(b);
      g[b].push_back(a);
      id[make_pair(a, b)] = i;
      id[make_pair(b, a)] = i;
    }
  }
  {
    used = vector<bool>(n, false);
    tin.resize(n);
    uptime.resize(n);
    for (int i = 0; i < (n); i++) {
      if (used[i]) continue;
      dfs_time(i);
    }
    used = vector<bool>(n, false);
    for (int i = 0; i < (n); i++) {
      if (used[i]) continue;
      dfs(i, -1);
    }
  }
  {}
  set<int> rez;
  {
    used = vector<bool>(n, false);
    for (int i = 0; i < (n); i++) {
      if (used[i]) continue;
      comp.clear();
      edges.clear();
      dfs_comp(i);
      if (((int)edges.size()) == ((int)comp.size()) * 2) {
        for (pair<int, int> p : edges) {
          rez.insert(id[p]);
        }
      }
    }
  }
  {
    smart_io::precall_print();
    cout, ((int)rez.size());
    vector<int> final(rez.begin(), rez.end());
    for (auto &first : final) {
      first++;
    };
    smart_io::precall_print();
    cout, final;
  }
}
