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 

#pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
// #include <atcoder/all>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vii = V<int>;
using vvll = V<vll>;
using vvii = V< V<int> >;
using PII = P<int, int>;
using PLL = P<ll, ll>;
#define RevREP(i,n,a) for(ll i=n;i>a;i--)  // (a,n]
#define REP(i,a,n) for(ll i=a;i<n;i++)  // [a,n)
#define rep(i, n) REP(i,0,n)
#define ALL(v) v.begin(),v.end()
#define eb emplace_back
#define pb push_back
#define sz(v) int(v.size())

template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; }
template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; }
template< class A, class B > ostream& operator <<(ostream& out, const P<A, B> &p) {
    return out << '(' << p.first << ", " << p.second << ')';
}
template< class A > ostream& operator <<(ostream& out, const V<A> &v) {
    out << '[';
    for (int i=0;i<int(v.size());i++) {
        if (i) out << ", ";
        out << v[i];
    }
    return out << ']';
}

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m; cin >> n >> m;
    V< V<PII> > edges(n);
    rep(i, m) {
        int a, b; cin >> a >> b;
        a--, b--;
        edges[a].eb(PII(b, i)), edges[b].eb(PII(a, i));
    }

    int k = 0;
    vii comp(n, -1);
    {
        set<PII> bridges;
        {
            vii low(n, INF), ord(n, -1);
            int t = 0;
            auto dfs = [&](auto && me, int i, int p) -> void {
                low[i] = t;
                ord[i] = t++;
                for (auto [e, ei]: edges[i]) {
                    if (e == p) continue;
                    if (ord[e] == -1) {
                        me(me, e, i);
                        low[i] = min(low[i], low[e]);
                        if (ord[i] < low[e]) bridges.insert(PII(min(i, e), max(i, e)));
                    } else {
                        low[i] = min(low[i], ord[e]);
                    }
                }
            };
            rep(i, n) if (ord[i] == -1) dfs(dfs, i, -1);
        }

        auto dfs = [&](auto && me, int i, int p) -> void {
            comp[i] = k;
            for (auto [e, ei]: edges[i]) {
                if (e == p or comp[e] != -1) continue;
                if (bridges.find(PII(min(i, e), max(i, e))) != bridges.end()) continue;
                me(me, e, i);
            }
        };
        rep(i, n) if (comp[i] == -1) {
            dfs(dfs, i, -1); k++;
        }
    }

    vvii nedge(k);
    vii nver(k, 0);
    rep(i, n) {
        nver[comp[i]]++;
        for(auto [e, ei]: edges[i]) {
            if (i > e) continue;
            if (comp[i] == comp[e]) nedge[comp[i]].eb(ei);
        }
    }

    vii ans;
    rep(i, k) {
        if (nver[i] == sz(nedge[i])) {
            for (int ei: nedge[i]) ans.eb(ei);
        }
    }
    sort(ALL(ans));

    cout << sz(ans) << '\n';
    rep(i, sz(ans)) {
        if (i != 0) cout << ' ';
        cout << ans[i] + 1;
    }
    cout << '\n';
    return 0;
}
