#include<iostream>
#include<queue>
#include<vector>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef vector<int> vi;
struct S{
	int s,r; vi his;
	S(int s=0,int r=0,vi p=vi(0)):s(s),r(r),his(p){}
};
int main(){
	int n,m,t1,t2;
	while(cin>>n>>m,n){
		bool ad[15][15]={0},sw[15][15]={0};
		int s=0;
		rep(i,m)cin>>t1>>t2,ad[t1-1][t2-1]=ad[t2-1][t1-1]=1;
		rep(i,n)cin>>t1,t1?s|=1<<i:0;
		rep(i,n){
			cin>>t1; rep(j,t1)cin>>t2,sw[i][t2-1]=1;
		}
		//ツδδつ可サツ探ツ催オ
		queue<S> F; bool V[1<<n][n],g=0,f=0; rep(i,1<<n)rep(j,n)V[i][j]=0;
		F.push(S(s,0,vi(0))); V[s][0]=1; vi ans;
		while(!F.empty()&&!f){
			S cs=F.front(),ns; F.pop();
			//ツ暗堋督ョ
			rep(i,n){
				ns=cs; ns.r=i;
				if(!ad[cs.r][i]||!(cs.s&(1<<i))||V[cs.s][i])continue;
				ns.his.push_back(i),F.push(ns),V[cs.s][i]=1;
				if(ns.r==n-1)g=1;
			}
			//ツ湘鳴セ
			rep(i,n){
				ns=cs; ns.s=cs.s^(1<<i);
				if(!sw[cs.r][i]||cs.r==i||V[ns.s][cs.r])continue;
				ns.his.push_back(i+((ns.s&(1<<i))?100:200)),F.push(ns),V[ns.s][cs.r]=1;
				if(ns.r==n-1&&ns.s==1<<(n-1))f=1,ans=ns.his;
			}
		}
		if(f){
			cout<<"You can go home in "<<ans.size()<<" steps."<<endl;
			rep(i,ans.size())cout<<(ans[i]>99?
				ans[i]>199?"Switch off":"Switch on":
				"Move to")<<" room "<<ans[i]%100+1<<"."<<endl;
		}else cout<<(g?"You can not switch off all lights.":"Help me!")<<endl;
	}
	return 0;
}