#include <bits/stdc++.h>
using namespace std;

#define for_(i,a,b) for(int i=a;i<b;++i)
#define for_rev(i,a,b) for(int i=a;i>=b;--i)
#define allof(a) a.begin(),a.end()
#define minit(a,b) memset(a,b,sizeof(a))
#define size_of(a) (int)a.size()

typedef long long lint;
typedef pair<int, int> pii;
typedef double Double;

inline int POPCNT(int _x) { return __builtin_popcount(_x); }
inline int POPCNT(lint _x) { return __builtin_popcountll(_x); }

const int iINF = 1L << 30;
const lint lINF = 1LL << 60;
const Double EPS = 1e-9;

typedef int flow_type;

struct DN_Edge {
	int to; flow_type cost; int rev; bool flag, rev_f; int id;
	DN_Edge(int _to, flow_type _cost, int _rev,
			bool _flag, bool _rev_f, int _id = -1) : to(_to), cost(_cost),
									 rev(_rev), flag(_flag), rev_f(_rev_f), id(_id) {}
};

struct Dinic {
	int V;
	vector< vector< DN_Edge > > edges;
	vector< int > level, iter;
	
	Dinic(int _n) : V(_n), edges(_n, vector< DN_Edge >()), level(_n, -1), iter(_n, 0) {}
	
	void add_edge(int _f, int _t, flow_type _c, bool flag, int id) {
		edges[_f].push_back(DN_Edge(_t, _c, size_of(edges[_t]), flag, false, id));
		edges[_t].push_back(DN_Edge(_f, flow_type(), size_of(edges[_f]) - 1, flag, true));
	}
	
	void bfs(int _s) {
		fill(allof(level), -1);
		queue<int> q; q.push(_s);
		level[_s] = 0;
		
		while (!q.empty()) {
			int v = q.front(); q.pop();
			int e_size = size_of(edges[v]);
			
			for_(i,0,e_size) {
				DN_Edge e = edges[v][i];
				if (e.cost > 0 && level[e.to] < 0) {
					level[e.to] = level[v] + 1;
					q.push(e.to);
				}
			}
		}
	}
	
	flow_type dfs(int _v, int _t, flow_type _f) {
		if (_v == _t) return _f;
		int e_size = size_of(edges[_v]);
		
		for (int &i = iter[_v]; i < e_size; ++i) {
			DN_Edge &e = edges[_v][i];
			
			if (e.cost > 0 && level[_v] < level[e.to]) {
				flow_type d = dfs(e.to, _t, min(_f, e.cost));
				if (d > 0) {
					e.cost -= d;
					edges[e.to][e.rev].cost += d;
					return d;
				}
			}
		}
		
		return -1;
	}
	
	flow_type max_flow(int _s, int _t) {
		flow_type flow = flow_type();
		while (1) {
			bfs(_s);
			if (level[_t] < 0) return flow;
			fill(allof(iter), 0);
			flow_type f;
			while ((f = dfs(_s, _t, iINF)) > 0) {
				flow += f;
			}
		}
	}
	
	pair<int, vector< int > > rev_cnt() {
		int resi = 0;
		vector< int > resv;
		
		for_(v,0,V) {
			int e_size = size_of(edges[v]);
			
			for_(i,0,e_size) {
				DN_Edge e = edges[v][i];
				
				if (!e.rev_f && e.flag && e.cost == 0) {
				//cout << "Edge(" << v << "," << e.to << "," << e.cost << "," << e.rev << "," 
				//	<< ( (e.flag) ? "rev" : "no_rev") << ")" << endl;
					resi++;
					resv.push_back(e.id);
				}
			}
		}
		
		return make_pair(resi, resv);
	}
};

int N, M;
int X[1010], Y[1010];
int S, T;

void solve() {
	Dinic dinic(N);
	for_(i,0,M) {
		dinic.add_edge(X[i] - 1, Y[i] - 1, 1, false, -1);
		dinic.add_edge(Y[i] - 1, X[i] - 1, 1, true, i + 1);
	}
	
	cout << dinic.max_flow(S - 1, T - 1) << endl;
	pair<int, vector< int > > piv = dinic.rev_cnt();
	
	cout << piv.first << endl;
	vector< int > ansv = piv.second;
	for_(i,0,size_of(ansv)) cout << ansv[i] << endl;
}

int main() {
	cin >> N >> M;
	for_(i,0,M) cin >> X[i] >> Y[i];
	cin >> S >> T;
	solve();
	return 0;
}

Measured memory_bytes: 1364