#define _CRT_SECURE_NO_WARNINGS
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
#define all(c) (c).begin(), (c).end()
#define loop(i,a,b) for(ll i=a; i<ll(b); i++)
#define rep(i,b) loop(i,0,b)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
template<class T> ostream & operator<<(ostream & os, vector<T> const &);
template<int n, class...T> typename enable_if<(n>=sizeof...(T))>::type _ot(ostream &, tuple<T...> const &){}
template<int n, class...T> typename enable_if<(n< sizeof...(T))>::type _ot(ostream & os, tuple<T...> const & t){ os << (n==0?"":" ") << get<n>(t); _ot<n+1>(os, t); }
template<class...T> ostream & operator<<(ostream & os, tuple<T...> const & t){ _ot<0>(os, t); return os; }
template<class T, class U> ostream & operator<<(ostream & os, pair<T,U> const & p){ return os << "(" << p.first << ", " << p.second << ") "; }
template<class T> ostream & operator<<(ostream & os, vector<T> const & v){ rep(i,v.size()) os << v[i] << (i+1==(int)v.size()?"":" "); return os; }
#ifdef DEBUG
#define dump(...) (cerr<<#__VA_ARGS__<<" = "<<mt(__VA_ARGS__)<<" ["<<__LINE__<<"]"<<endl)
#else
#define dump(...)
#endif

int const inf = 1<<29;
struct Dinic {
public:
    typedef int Capacity;
    struct Edge;
    int n;
    vector<vector<Edge> > g;
    vector<int> level, iter;

    struct Edge {
        int dst;
        Capacity cap, cap_orig;
        int revEdge;
        bool isRev;
        bool isRev2;
        int id;
        Edge(int dst_, Capacity cap_, int revEdge_, bool isRev_, bool isRev2_, int id_)
            :dst(dst_), cap(cap_), cap_orig(cap_), revEdge(revEdge_), isRev(isRev_), isRev2(isRev2_), id(id_) {
        }
    };

    Dinic(int n_)
        : n(n_), g(vector<vector<Edge> >(n_)), level(n_), iter(n_) {}

    void add_edge(int src, int dst, Capacity cap, bool isRev2, int id){
        g[src].emplace_back(Edge(dst, cap, g[dst].size(), false, isRev2, id));
        g[dst].emplace_back(Edge(src, 0, g[src].size() - 1, true, isRev2, id));
    }

    // src->dstへの最大フローを流す
    Capacity solve(int src, int dst) {
        int flow = 0;
        while(1){
            bfs(src);
            if (level[dst] < 0) return flow;
            fill(all(iter), 0);
            int f;
            while ((f = dfs(src, dst, inf)) > 0) {
                flow += f;
            }
        }
    }

private:
    void bfs(int s) {
        level.assign(n,-1);
        queue<int> q; // 辺の数でみた最短距離
        level[s] = 0;
        q.push(s);
        while (q.size()) {
            int v = q.front(); q.pop();
            rep(i,g[v].size()){
                Edge& e = g[v][i];
                if (e.cap > 0 && level[e.dst] < 0) {
                    level[e.dst] = level[v] + 1;
                    q.push(e.dst);
                }
            }
        }
    }

    Capacity dfs(int v, int t, int f) {
        if (v == t) return f;
        for (int &i = iter[v]; i < (int)g[v].size(); i++) {
            Edge &e = g[v][i];
            if (e.cap > 0 && level[v] < level[e.dst]) {
                int d = dfs(e.dst, t, min(f, e.cap));
                if (d > 0) {
                    e.cap -= d;
                    g[e.dst][e.revEdge].cap += d;
                    return d;
                }
            }
        }
        return 0;
    }

public:
    // 現在の容量を表示
    // フローを流した分だけ破壊的に容量が減る実装になっている
    void view(){
        rep(i,g.size()){
            rep(j,g[i].size()){
                Edge & e=g[i][j];
                if(!e.isRev) printf("%3d->%3d (flow:%d)\n", (int)i, e.dst, e.cap);
            }
        }
    }

    // 流れたフロー=元々の容量-現在の容量を表示
    void view_flow(){
        rep(i,g.size()){
            rep(j,g[i].size())if(!g[i][j].isRev){
                Edge& e = g[i][j];
                printf("%3d->%3d (flow:%d)\n", (int)i, e.dst, e.cap_orig - e.cap);
            }
        }
    }

    void doit(){
        vector<int> ans;
        rep(i,g.size()){
            rep(j,g[i].size()){
                if(!g[i][j].isRev && g[i][j].isRev2 && g[i][j].cap==0){
                    ans.pb(g[i][j].id);
                }
            }
        }
        cout << ans.size() << endl;
        rep(i,ans.size()){
            cout << ans[i] << endl;
        }
    }
};

int main(){
    int n,m;
    while(cin >> n >> m){
        Dinic g(n);
        rep(i,m){
            int x,y; cin >> x >> y;
            x--; y--;
            g.add_edge(x,y,1,false,i+1);
            g.add_edge(y,x,1,true,i+1);
        }
        int s,t;
        cin >> s >> t;
        s--; t--;
        int f = g.solve(s,t);
        cout << f << endl;
        g.doit();
    }
}

Measured memory_bytes: 1368