#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>
#include <cassert>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

typedef long long int ll;
using ll = long long int;
using ull = long long unsigned int;
using Int = long long int;
using uInt = long long unsigned int;
using Double = long double;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//edit
class Flow {
public:
    struct edge {
        int to, cap, rev;
    };
    vector<vector<edge>> G;
    vector<bool> used;

    //0 ~ maxSize-1 のフローを構築できるようにする
    explicit Flow(unsigned maxSize) {
        G.resize(maxSize, vector<edge>());
        used.resize(maxSize, false);
    }

    void add_edge(int from, int to, int cap) {
        G[from].push_back((edge) {to, cap, (int) G[to].size()});
//        G[to].push_back((edge) {from, 0, (int) G[from].size() - 1});
        G[to].push_back((edge) {from, cap, (int) G[from].size() - 1});
    }

    //増加パスを探す
    int dfs(int v, int t, int f) {
        if (v == t) return f;
        used[v] = true;
        for (int i = 0; i < G[v].size(); i++) {
            edge &e = G[v][i];
            if (!used[e.to] && e.cap > 0) {
                int d = dfs(e.to, t, min(f, e.cap));
                if (d > 0) {
                    e.cap -= d;
                    G[e.to][e.rev].cap += d;
                    return d;
                }
            }
        }
        return 0;
    }

    int max_flow(int s, int t) {
        int flow = 0;
        for (;;) {
            rep(i, 0, used.size())used[i] = false;
            int f = dfs(s, t, INF);
            if (f == 0) return flow;
            flow += f;
        }
    }

};

class Solve {
public:
    void solve() {
        Int N, M;
        Int S, T;
        cin >> N >> M;
        struct edge {
            int to, id;
        };
//        vector<vector<edge>> G(N);
        map<pair<int, int>, int> mp;
        Flow flow(N);

        for (int i = 0; i < M; ++i) {
            int a, b;
            cin >> a >> b;
            a--, b--;
            mp[make_pair(a, b)] = i;
//            G[a].push_back(edge({b, i});
            flow.add_edge(a, b, 1);
        }

        cin >> S >> T;
        S--, T--;

        Int max_flow = flow.max_flow(S, T);
        vector<pair<int, int>> flowed_edge;
        for (int i = 0; i < flow.G.size(); ++i) {
            for (auto e : flow.G[i]) {
                if (e.cap == 0) {
                    flowed_edge.emplace_back(i, e.to);
                }
            }
        }

        set<int> reversed_edge;
        for (auto e : flowed_edge) {
            if (mp.count(e)) {
            } else {
                auto re = make_pair(e.second, e.first);
                int tmp = mp[re];
                reversed_edge.insert(tmp);
            }
        }

        cout << max_flow << endl;
        cout << reversed_edge.size() << endl;
        for (auto e : reversed_edge) {
            cout << e + 1 << endl;
        }

    }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
//    std::ifstream in("input.txt");
//    std::cin.rdbuf(in.rdbuf());

    Solve().solve();


    return 0;
}



Measured memory_bytes: 3320