#include<stdio.h>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
vector<int>g[20];
int bfs[1<<15][15];
int rev[1<<15][15];
int r[16];
int can[16][16];
int ans[1000000];
int main(){
	int a,b;
	while(scanf("%d%d",&a,&b),a){
		for(int i=0;i<a;i++)g[i].clear();
		for(int i=0;i<b;i++){
			int p,q;
			scanf("%d%d",&p,&q);p--;q--;
			g[p].push_back(q);
			g[q].push_back(p);
		}
		for(int i=0;i<a;i++)scanf("%d",r+i);
		for(int i=0;i<a;i++)for(int j=0;j<a;j++)can[i][j]=0;
		for(int i=0;i<a;i++){
			int c;scanf("%d",&c);
			for(int j=0;j<c;j++){
				int d;scanf("%d",&d);
				d--;
				can[i][d]=1;
			}
		}
		for(int i=0;i<(1<<a);i++)for(int j=0;j<a;j++)
			bfs[i][j]=-1;
		int now=0;
		for(int i=0;i<a;i++)now+=r[i]*(1<<i);
		bfs[now][0]=0;
		queue<pair<int,int> > Q;
		Q.push(make_pair(now,0));
		while(Q.size()){
			int bit=Q.front().first;
			int at=Q.front().second;
			Q.pop();
			for(int i=0;i<g[at].size();i++){
				if((bit&(1<<g[at][i]))&&!~bfs[bit][g[at][i]]){
					bfs[bit][g[at][i]]=bfs[bit][at]+1;
					rev[bit][g[at][i]]=at;
					Q.push(make_pair(bit,g[at][i]));
				}
			}
			for(int i=0;i<a;i++){
				if(can[at][i]&&!~bfs[bit^(1<<i)][at]){
					bfs[bit^(1<<i)][at]=bfs[bit][at]+1;
					rev[bit^(1<<i)][at]=-1-i;
					Q.push(make_pair(bit^(1<<i),at));
				}
			}
		}
		if(~bfs[(1<<(a-1))][a-1]){
			printf("You can go home in %d steps.\n",bfs[(1<<(a-1))][a-1]);
			int bit=(1<<(a-1));
			int at=a-1;
			for(int i=0;i<bfs[(1<<(a-1))][a-1];i++){
				
				if(rev[bit][at]>=0){
					ans[bfs[(1<<(a-1))][a-1]-i-1]=at;
					at=rev[bit][at];
				}
				else{
					ans[bfs[(1<<(a-1))][a-1]-i-1]=rev[bit][at];
					bit^=(1<<(-rev[bit][at]-1));
				}
			}
			for(int i=0;i<bfs[(1<<(a-1))][a-1];i++){
				if(ans[i]>=0)printf("Move to room %d.\n",ans[i]+1);
				else if(now&(1<<(-ans[i]-1))){
					printf("Switch off room %d.\n",-ans[i]);
					now^=(1<<(-ans[i]-1));
				}else {
					printf("Switch on room %d.\n",-ans[i]);
					now^=(1<<(-ans[i]-1));
				}
			}
		}else{
			bool ok=false;
			for(int i=0;i<(1<<a);i++)if(~bfs[i][a-1])ok=true;
			if(ok)printf("You can not switch off all lights.\n");
			else printf("Help me!\n");
		}
	}
}