#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <queue>
#include <vector>
#include <functional>
#define INF 1<<30
#define MAX_V 16

using namespace std;
typedef pair<int,int> P;
class data{
public:
	int cost,v,bit;
	data(){}
	data(int vv,int bb,int cc){
		cost=cc;
		v=vv;
		bit=bb;
	}
	bool operator<(const data &d)const{
		return cost>d.cost;
	}
};
int n,m;
vector<int> G[MAX_V];
int s[MAX_V];
int dp[MAX_V][1<<MAX_V];
int pv[MAX_V][1<<MAX_V],pbit[MAX_V][1<<MAX_V];
bool flag;
int dijk(int x){
	if(!(x & 1))return -1;
	for(int i=0;i<n;i++){
		for(int j=0;j<(1<<n);j++){
			dp[i][j]=INF;
			pv[i][j]=-1;
			pbit[i][j]=-1;
		}
	}
	priority_queue<data> que;
	que.push(data(0,x,0));
	dp[0][x]=0;
	while(que.size()){
		data q=que.top();
		que.pop();
		if(q.cost>dp[q.v][q.bit])continue;
		if(q.v==n-1 && q.bit==1<<(n-1))return q.cost;
		if(q.v==n-1)flag=true;
		for(int i=0;i<G[q.v].size();i++){
			int t=G[q.v][i];
			if(dp[t][q.bit]>q.cost+1 && (q.bit>>t & 1)){
				dp[t][q.bit]=q.cost+1;
				pv[t][q.bit]=q.v;
				pbit[t][q.bit]=q.bit;
				que.push(data(t,q.bit,q.cost+1));
			}
		}
		for(int i=0;i<n;i++){
			if(i==q.v)continue;
			if(pv[q.v][q.bit]==q.v && abs(q.bit-pbit[q.v][q.bit])>(1<<i))continue;
			if(s[q.v]>>i & 1){
				int nbit=q.bit^(1<<i);
				if(dp[q.v][nbit]>q.cost+1){
					dp[q.v][nbit]=q.cost+1;
					pv[q.v][nbit]=q.v;
					pbit[q.v][nbit]=q.bit;
					que.push(data(q.v,nbit,q.cost+1));
				}
			}
		}
	}
	return -1;
}

int main(void){
	while(1){
		scanf("%d%d",&n,&m);
		if(n+m==0)break;
		for(int i=0;i<m;i++){
			int f,t;
			scanf("%d%d",&f,&t);
			f--;
			t--;
			G[f].push_back(t);
			G[t].push_back(f);
		}
		int st=0;
		for(int i=0;i<n;i++){
			int a;
			scanf("%d",&a);
			st+=a<<i;
		}
		for(int i=0;i<n;i++){
			int a;
			scanf("%d",&a);
			for(int j=0;j<a;j++){
				int b;
				scanf("%d",&b);
				b--;
				s[i]|=1<<b;
			}
		}
		flag=false;
		int res=dijk(st);
		if(res==-1){
			if(!flag)printf("Help me!\n");
			else printf("You can not switch off all lights.\n");
		}else{
			printf("You can go home in %d steps.\n",res);
			vector<P> vec;
			int v=n-1,bit=1<<(n-1);
			while(v!=-1){
				vec.push_back(P(v,bit));
				int nv=pv[v][bit];
				int nbit=pbit[v][bit];
				v=nv;
				bit=nbit;
			}
			reverse(vec.begin(),vec.end());
			for(int i=0;i<(int)vec.size()-1;i++){
				if(vec[i].first!=vec[i+1].first)printf("Move to room %d.\n",vec[i+1].first+1);
				else{
					int a=abs(vec[i].second-vec[i+1].second);
					int cnt=1;
					while(a>1){
						a/=2;
						cnt++;
					}
					printf("Switch %s room %d.\n",vec[i].second>vec[i+1].second?"off":"on",cnt);
				}
			}
		}
		memset(s,0,sizeof(s));
		for(int i=0;i<n;i++){
			G[i].clear();
		}
	}
	return 0;
}