#include<cstdio>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<vector>
#include<deque>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<string>
#include<sstream>
#include<ctime>
#define eps 1e-9
#define ALL(x) x.begin(),x.end()
#define INS(x) inserter(x,x.begin())
#define rep(i,j,k) for(int i=j;i<=k;i++)
#define MAXN 10005
#define MAXM 40005
#define INF 0x3fffffff
#define PB push_back
#define MP make_pair
#define X first
#define Y second
#define lc (k<<1)
#define rc ((k<<1)|1)
#define mii ((l+r)>>1)
#define fk puts("fuck!")
#define clr(x,y) memset(x,y,sizeof(x))
using namespace std;
typedef long long LL;
int i,j,k,n,m,x,y,T,mx,mi,cas,num,len;
bool flag;


const int inf = 0x3f3f3f3f;
struct edgenode
{
    int from,to,next,flag;
    int cap;
}edge[MAXM];
int Edge,head[MAXN],ps[MAXN],dep[MAXN];

void add_edge(int x,int y,int c,int flag)
{
    edge[Edge].from=x;
    edge[Edge].to=y;
    edge[Edge].cap=c;
    edge[Edge].flag=flag;
    edge[Edge].next=head[x];
    head[x]=Edge++;

    edge[Edge].from=y;
    edge[Edge].to=x;
    edge[Edge].cap=0;
    edge[Edge].flag=flag;
    edge[Edge].next=head[y];
    head[y]=Edge++;
}

int dinic(int n,int s,int t)
{
    int tr,flow=0;
    int i,j,k,l,r,top;
    while(1){
        memset(dep,-1,(n+1)*sizeof(int));
        for(l=dep[ps[0]=s]=0,r=1;l!=r;)//BFS部分，将?定?分?
        {
            for(i=ps[l++],j=head[i];j!=-1;j=edge[j].next)
            {
                if (edge[j].cap&&-1==dep[k=edge[j].to])
                {
                    dep[k]=dep[i]+1;ps[r++]=k;
                    if(k==t)
                    {
                        l=r;
                        break;
                    }
                }
            }
        }
        if(dep[t]==-1)break;

        for(i=s,top=0;;)//DFS部分
        {
            if(i==t)//当前点就是?点?
            {
                for(k=0,tr=inf;k<top;++k)
                    if(edge[ps[k]].cap<tr)tr=edge[ps[l=k]].cap;

                for(k=0;k<top;++k)
                    edge[ps[k]].cap-=tr,edge[ps[k]^1].cap+=tr;

                flow+=tr;
                i=edge[ps[top=l]].from;
            }

            for(j=head[i];j!=-1;j=edge[j].next)//找当前点所指向的点
                if(edge[j].cap&&dep[i]+1==dep[edge[j].to]) break;

            if(j!=-1)
            {
                ps[top++]=j;//当前点有所指向的点，把?个点加入?中
                i=edge[j].to;
            }
            else
            {
                if (!top) break;//当前点没有指向的点，回溯
                dep[i]=-1;
                i=edge[ps[--top]].from;
            }
        }
    }
    return flow;
}

vector<int> ans;
int main()
{
    memset(head,-1,sizeof(head));
    Edge=0;
	scanf("%d%d",&n,&m);
    for (i=1;i<=m;i++)
    {
        scanf("%d%d",&x,&y);
        add_edge(x,y,1,1);
        add_edge(y,x,1,0);
    }
    int S,T;
    scanf("%d%d",&S,&T);
    printf("%d\n",dinic(n+3,S,T));

    ans.clear();
    for (i=0;i<Edge;i+=2)
    {
        if (edge[i].flag==0 && edge[i].cap==0)
        {
            ans.PB(i/4+1);
        }
    }
    printf("%d\n",ans.size());
    for (i=0;i<ans.size();i++)
    {
        printf("%d\n",ans[i]);
    }
	return 0;
}