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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define rrev(i, m, n) for(int (i)=(n)-1; (i)>=(m); (i)--)
#define erev(i, m, n) for(int (i)=(n); (i)>=(m); (i)--)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define pb            push_back
#define mp            make_pair
template<class T, class S> inline bool minup(T& m, const S x){ return m>(T)x ? (m=(T)x, true) : false; }
template<class T, class S> inline bool maxup(T& m, const S x){ return m<(T)x ? (m=(T)x, true) : false; }

static const int    INF = 1000000000;
static const ll     MOD = 1000000007LL;
static const double EPS = 1E-10;

template<typename T> struct edge
{
  int to;
  T cap;
  int reverse;
  int id;
  edge(int to, T cap, int reverse, int id) : to(to), cap(cap), reverse(reverse), id(id) {}
};

template <typename T> class Dinic
{
private:
  static const T INF = (T)1000000000;
  vector<edge<T> >* G;
  int N;
  int* level;
  int* iter;

  void bfs(int s);
  T dfs(int v, int t, T f);

public:
  Dinic(int N) : N(N) { this->init(); }
  void init();
  void addEdge(int from, int to, T cap, int id);
  T MaximumFlow(int s, int t);
  pair<T, vector<int> > solve(int s, int t);
};

template<typename T> void Dinic<T>::init()
{
  G = new vector<edge<T> >[N];
  level = new int[N];
  iter = new int[N];
  rep(i, N) G[i].clear();
}

template<typename T> void Dinic<T>::addEdge(int from, int to, T cap, int id)
{
  G[from].pb(edge<T>(to, cap, G[to].size(), id));
  G[to].pb(edge<T>(from, cap, G[from].size()-1, -id));
}

template<typename T> void Dinic<T>::bfs(int s)
{
  rep(i, N) level[i] = -1;
  queue<int> que;
  level[s] = 0;
  que.push(s);
  while(!que.empty()){
    int v = que.front();  que.pop();
    vrep(w, G[v]){
      edge<T>& e = *w;
      if(e.cap > (T)0 && level[e.to] < 0){
        level[e.to] = level[v] + 1;
        que.push(e.to);
      }
    }
  }
}

template<typename T> T Dinic<T>::dfs(int v, int t, T f)
{
  if(v == t) return f;
  for(int& i = iter[v]; i<G[v].size(); i++){
    edge<T>& e = G[v][i];
    if(e.cap > (T)0 && level[v] < level[e.to]){
      T d = dfs(e.to, t, min(f, e.cap));
      if(d > (T)0){
        e.cap -= d;
        G[e.to][e.reverse].cap += d;
        return d;
      }
    }
  }
  return 0;
}

template<typename T> T Dinic<T>::MaximumFlow(int s, int t)
{
  T flow = (T)0;
  while(true){
    bfs(s);
    if(level[t] < (T)0) return flow;
    rep(i, N) iter[i] = 0;
    T f;
    while((f = dfs(s, t, Dinic::INF)) > (T)0){
      flow += f;
    }
  }
}

template<typename T> pair<T, vector<int> > Dinic<T>::solve(int s, int t)
{
  T mx = this->MaximumFlow(s, t);
  vi ret;
  rep(i, N) vrep(v, G[i]) if(v->cap == 0 && v->id < 0) ret.pb(-v->id);
  sort(ALL(ret));
  return mp(mx, ret);
}

int N, M;
int S, T;
int x, y;
int mx;

int main(int argc, char *argv[])
{
  cin >> N >> M;
  Dinic<int> dinic(N);

  rep(i, M){
    cin >> x >> y;
    dinic.addEdge(x - 1, y - 1, 1, i + 1);
  }
  cin >> S >> T;
  
  pair<int, vi> res = dinic.solve(S - 1, T - 1);
  cout << res.first << endl;
  cout << res.second.size() << endl;
  vrep(v, res.second) cout << *v << endl;
  
  return 0;
}

Measured memory_bytes: 1292