#include<iostream>
#include<queue>
#include<map>
#include<vector>
#include<algorithm>
using namespace std;
int N,M;
struct state{
	int now,L;
	bool operator<(const state&a)const{
		return L*15+now<a.L*15+a.now;
	}
};
main()
{
	while(cin>>N>>M,N)
	{
		map<state,int>A;
		vector<int>G[15];
		vector<int>L[15];
		for(int i=0;i<M;i++)
		{
			int u,v;cin>>u>>v;
			u--,v--;
			G[u].push_back(v);
			G[v].push_back(u);
		}
		queue<state>P;
		state start;
		start.now=start.L=0;
		for(int i=0;i<N;i++)
		{
			int l;cin>>l;
			start.L|=l<<i;
		}
		for(int i=0;i<N;i++)
		{
			int k;cin>>k;
			for(;k--;)
			{
				int id;cin>>id;id--;
				L[i].push_back(id);
			}
			sort(L[i].rbegin(),L[i].rend());
		}
		P.push(start);
		A[start]=0;
		while(!P.empty())
		{
			state now=P.front();P.pop();
			int turn=A[now];
			for(int id:L[now.now])
			{
			    if(id==now.now)continue;
				now.L^=1<<id;
				if(A.find(now)==A.end())
				{
					P.push(now);
					A[now]=turn+1;
				}
				now.L^=1<<id;
			}
			for(int v:G[now.now])
			{
				if(now.L>>v&1)
				{
					int tmp=now.now;
					now.now=v;
					if(A.find(now)==A.end())
					{
						P.push(now);
						A[now]=turn+1;
					}
					now.now=tmp;
				}
			}
		}
		state goal;
		goal.now=N-1;
		goal.L=1<<N-1;
		if(A.find(goal)!=A.end())
		{
			int X=A[goal];
			cout<<"You can go home in "<<X<<" steps."<<endl;
			vector<string>ans(X);
			for(;X--;)
			{
				for(int id:L[goal.now])
				{
					goal.L^=1<<id;
					if(A.find(goal)!=A.end()&&A[goal]==X)
					{
						if(goal.L>>id&1)ans[X]="Switch off room "+to_string(id+1)+".";
						else ans[X]="Switch on room "+to_string(id+1)+".";
						break;
					}
					goal.L^=1<<id;
				}
				if(ans[X]=="")
				{
					for(int v:G[goal.now])
					{
						int tmp=goal.now;
						goal.now=v;
						if(A.find(goal)!=A.end()&&A[goal]==X)
						{
							ans[X]="Move to room "+to_string(tmp+1)+".";
							break;
						}
						goal.now=tmp;
					}
				}
			}
			for(const string&s:ans)cout<<s<<endl;
		}
		else
		{
			bool flag=false;
			for(map<state,int>::iterator it=A.begin();it!=A.end();it++)
			{
				flag|=it->first.now==N-1;
				if(flag)break;
			}
			cout<<(flag?"You can not switch off all lights.":"Help me!")<<endl;
		}
	}
}
