#include <bits/stdc++.h>

using namespace std;

struct Edge {
	int to, cap, rev;
};

vector< vector<Edge> > G;
vector<bool> used;
int dfs(int s, int t, int f) {
	if (s == t) return f;
	used[s] = true;

	for (int i = 0; i < G[s].size(); ++i) {
		Edge& e = G[s][i];
		if (!used[e.to] && e.cap > 0) {
			int d = dfs(e.to, t, min(e.cap, f));
			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 res = 0;
	while (1) {
		int N = G.size();
		used = vector<bool>(G.size(), false);
		int flow = dfs(s, t, 1e9);
		if (flow > 0) {
			res += flow;
		}
		else {
			break;
		}
	}
	return res;
}
void add_edge(int u, int v, int cap) {
	G[u].push_back((Edge){v, cap, (int)G[v].size()});
	G[v].push_back((Edge){u, cap, (int)G[u].size()-1});
}

typedef pair<int, int> P;

int main() {
	int N, M; cin >> N >> M;
	G.resize(N);
	vector<P> edges;
	map<P, int> tbl;
	for (int i = 0; i < M; ++i) {
		int a, b; cin >> a >> b; --a, --b;
		edges.push_back( P(a, b) );
		tbl[edges[i]] = i;
	}
	for (int i = 0; i < M; ++i) {
		int u = edges[i].first, v = edges[i].second;
		add_edge(u, v, 1);
	}
	int S, T; cin >> S >> T; --S, --T;
	cout << max_flow(S, T) << endl;

	vector<int> ans;
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < G[i].size(); ++j) {
			Edge& e = G[i][j];
			if (e.cap == 0) {
				if (tbl.find(P(e.to, i)) != tbl.end()) {
					ans.push_back(tbl[P(e.to, i)]+1);
				}
			}
		}
	}
	sort(ans.begin(), ans.end());
	cout << ans.size() << endl;
	for (int i = 0; i < ans.size(); ++i) {
		cout << ans[i] << endl;
	}
}