#include #include #include #include #include #include #include #include #include #include #include #include #pragma comment(linker, "/STACK:102400000,102400000") using namespace std; const int N=105; const int MAX=1000000100; const int mod=100000000; const int MOD1=1000000007; const int MOD2=1000000009; const double EPS=0.00000001; typedef long long ll; const ll MOD=998244353; const int INF=1000000010; const double pi=acos(-1.0); typedef double db; typedef unsigned long long ull; int tot,u[2*N],v[2*N*N],cap[2*N*N],flow[2*N*N],pre[2*N*N]; void add(int a,int b,int c,int f) { v[tot]=b;flow[tot]=f;cap[tot]=c;pre[tot]=u[a];u[a]=tot++; } bool q[2*N]; int d[2*N],dis[2*N],head[2*N]; bool bfs(int x,int y) { int i,l=1,r=1; memset(q,0,sizeof(q)); d[1]=x;q[x]=1;dis[x]=0; for (;l<=r;l++) for (i=u[d[l]];i!=-1;i=pre[i]) if (!q[v[i]]&&cap[i]-flow[i]) d[++r]=v[i],q[v[i]]=1,dis[v[i]]=dis[d[l]]+1; return q[y]; } int dfs(int x,int a,int en) { if (x==en||a==0) return a; int ret=0,f; for (int& i=u[x];i!=-1;i=pre[i]) if (dis[v[i]]==dis[x]+1&&(f=dfs(v[i],min(a,cap[i]-flow[i]),en))>0) { flow[i]+=f;flow[i^1]-=f; ret+=f;a-=f; if (a==0) break ; } return ret; } int n,f[2][2*N]; void out(int x,int y) { if (x<=n) f[y][++f[y][0]]=x; for (int i=u[x];i!=-1;i=pre[i]) if (flow[i]>0) out(v[i],y); } int main() { int a,b,i,m,t,x,y,z; scanf("%d", &t); while (t--) { scanf("%d%d", &n, &m); scanf("%d%d%d", &x, &y, &z); tot=0;memset(u,-1,sizeof(u)); for (i=1;i<=n;i++) add(i,i+n,1+(i==z),0),add(i+n,i,0,0); for (i=1;i<=m;i++) { scanf("%d%d", &a, &b); add(a+n,b,1,0);add(b,a+n,0,0); add(b+n,a,1,0);add(a,b+n,0,0); } add(0,z,2,0);add(z,0,0,0); add(x+n,2*n+1,1,0);add(2*n+1,x+n,0,0); add(y+n,2*n+1,1,0);add(2*n+1,y+n,0,0); for (i=0;i<=2*n+1;i++) head[i]=u[i]; while (bfs(0,2*n+1)) { dfs(0,2,2*n+1); for (i=0;i<=2*n+1;i++) u[i]=head[i]; } f[0][0]=f[1][0]=tot=0; for (i=u[z+n];i!=-1;i=pre[i]) if (flow[i]>0) out(v[i],tot++); if (f[0][f[0][0]]==x) { for (i=f[0][0];i;i--) printf("%d ", f[0][i]); printf("%d ", z); for (i=1;i