#include<iostream>
#include<vector>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define foreach(i,c) for(__typeof(c.begin()) i=c.begin();i!=c.end();i++)
#define mp make_pair
using namespace std;
typedef vector<int> vi;
int main(){
	int m,n,t,u;
	while(cin>>n>>m,n){
		vector<vi> dr(n,vector<int>(n)),sw(n);
		rep(i,m)cin>>t>>u,t--,u--,dr[t][u]=dr[u][t]=1;
		vi li(n); rep(i,n)cin>>li[i];
		rep(i,n){
			cin>>t;
			rep(j,t)cin>>u,sw[i].push_back(--u);
		}
		map<vi,vi> frontier,visited;
		vi st(n),phi(0); st=li,st.push_back(0);
		frontier.insert(mp(st,phi)); visited.insert(mp(st,phi));
		int finished=0,goaled=0,cleared=0;
		vi goal(n+1); goal[n-1]=1; goal[n]=n-1;
		while(!finished&&!frontier.empty()){
			finished=1;
			foreach(i,frontier){
				vi cstate,cstep,nstate,nstep;
				cstate=i->first,cstep=i->second;
				int crm=cstate[n];
				rep(j,n){
					if(dr[crm][j]&&cstate[j]&&crm!=j){
						nstate=cstate; nstate[n]=j;
						nstep=cstep; nstep.push_back(j);
						if(visited.find(nstate)!=visited.end())continue;
						frontier.insert(mp(nstate,nstep));
						visited.insert(mp(nstate,nstep));
						if(nstate[n]==n-1)goaled=1;
						if(nstate==goal)cleared=finished=1;
						finished=0; goto NEXT;
					}
				}
				rep(j,sw[crm].size()){
					nstate=cstate; nstep=cstep;
					t=sw[crm][j]; u=nstate[t];
					nstate[t]^=1;
					nstep.push_back(100*(u+1)+t);
					if(visited.find(nstate)!=visited.end())continue;
					frontier.insert(mp(nstate,nstep));
					visited.insert(mp(nstate,nstep));
					if(nstate[n]==n-1)goaled=1;
					if(nstate==goal)cleared=finished=1;
					finished=0; goto NEXT;
				}
				frontier.erase(i); finished=0; goto NEXT;
			}
			NEXT:;
		}
		if(cleared){
			vi step=visited[goal];
			vi ans;
			rep(i,step.size()){
				map<int,int> ssw;
				while(i<step.size()&&step[i]>99){
					if(ssw.find(step[i]%100)==ssw.end())ssw[step[i]%100]=step[i];
					else ssw.erase(ssw.find(step[i]%100));
					i++;
				}
				foreach(j,ssw)ans.push_back(j->second);
				ssw.clear();
				if(i<step.size())ans.push_back(step[i]);
			}
			cout<<"You can go home in "<<ans.size()<<" steps."<<endl;
			rep(i,ans.size()){
				if(ans[i]<100)cout<<"Move to";
				else cout<<"Switch "<<(ans[i]<200?"on":"off");
				cout<<" room "<<ans[i]%100+1<<"."<<endl;
			}
		}else cout<<(goaled?"You can not switch off all lights.":"Help me!")<<endl;
	}
	return 0;
}