#include<queue>
#include<string>
#include<cstdio>
#include<algorithm>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

int main(){
	for(int n,m;scanf("%d%d",&n,&m),n;){
		vector<int> G[15];
		rep(i,m){
			int u,v; scanf("%d%d",&u,&v); u--; v--;
			G[u].push_back(v);
			G[v].push_back(u);
		}

		int S_ini=0;
		rep(u,n){
			int b; scanf("%d",&b);
			S_ini|=b<<u;
		}

		vector<int> sw[15];
		rep(u,n){
			int k; scanf("%d",&k);
			sw[u].resize(k);
			rep(i,k) scanf("%d",&sw[u][i]), sw[u][i]--;
			sort(sw[u].begin(),sw[u].end());
		}

		if((S_ini&1<<0)==0){
			puts("Help me!");
			continue;
		}

		static int d[15][1<<15];
		static char msg[15][1<<15][32];
		static pair<int,int> pre[15][1<<15];
		rep(u,n) rep(S,1<<n) d[u][S]=-1;
		d[0][S_ini]=0;

		queue< pair<int,int> > Q;
		Q.push(make_pair(0,S_ini));
		while(!Q.empty()){
			int u=Q.front().first,S=Q.front().second; Q.pop();

			// スイッチ切り替え
			rep(i,sw[u].size()){
				int v=sw[u][i];
				if(d[u][S^1<<v]==-1 && v!=u){
					d[u][S^1<<v]=d[u][S]+1;
					if(S&1<<v) sprintf(msg[u][S^1<<v],"Switch off room %d.",v+1);
					else       sprintf(msg[u][S^1<<v],"Switch on room %d.",v+1);
					pre[u][S^1<<v]=make_pair(u,S);
					Q.push(make_pair(u,S^1<<v));
				}
			}
			// 部屋移動
			rep(i,G[u].size()){
				int v=G[u][i];
				if(d[v][S]==-1 && S&1<<v){
					d[v][S]=d[u][S]+1;
					sprintf(msg[v][S],"Move to room %d.",v+1);
					pre[v][S]=make_pair(u,S);
					Q.push(make_pair(v,S));
				}
			}
		}

		if(d[n-1][1<<n-1]!=-1){
			printf("You can go home in %d steps.\n",d[n-1][1<<n-1]);
			vector<string> path;
			int u=n-1,S=1<<n-1;
			while(u!=0 || S!=S_ini){
				path.push_back(msg[u][S]);
				pair<int,int> tmp=pre[u][S];
				u=tmp.first;
				S=tmp.second;
			}
			reverse(path.begin(),path.end());
			rep(i,path.size()) puts(path[i].c_str());
		}
		else{
			bool b=false;
			rep(S,1<<n) if(d[n-1][S]!=-1) b=true;
			puts(b?"You can not switch off all lights.":"Help me!");
		}
	}

	return 0;
}