#include <iostream>
#include <vector>
#include <sstream>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i = 0 ; i < n ; i++)

struct NODE{
	int pos , bit;
	NODE(int a,int b){ pos = a ; bit = b;}
	NODE(){}
};

NODE *done[1<<15][15];
NODE Q[(1<<15)*15];
int n,m;

bool diff(int a,int b,vector<string> &ans){
	int bit = a ^ b;
	bool f = false;
	rep(i,n){
		if( (a>>i&1)^(b>>i&1)){
			f = true;
			stringstream ss;
			ss << "Switch " << (a>>i&1?"on":"off") << " room " << i+1 << ".";
			ans.push_back(ss.str());
		}
	}
	return f;
}

int main(){
	while(cin >> n >> m && n){
		vector< vector<int> > v(n);
		vector< vector<int> > room(n);
		rep(i,m){
			int a,b;
			cin >> a >> b;
			a--,b--;
			v[a].push_back(b);
			v[b].push_back(a);
		}
		rep(i,n) sort(v[i].begin(),v[i].end());
		int init = 0;
		rep(i,n){
			int a; cin >> a;
			init |= (a<<i);
		}
		rep(i,n){
			int c; cin >> c;
			rep(j,c){
				int a; cin >> a;a--;
				if(a != i) room[i].push_back(1<<a);
			}
			sort(room[i].begin(),room[i].end());
		}
		rep(i,1<<n)rep(j,n) done[i][j] = NULL;
		int head = 0 , size = 0 , ansbit = (1<<30); 
		bool flag = false;
		Q[size++] = NODE(0,init);
		done[init][0] = &Q[head];
		while(head < size){
			NODE q = Q[head];
			if(q.pos == n-1){
				if( q.bit == (1<<(n-1)) ){
					vector<string> a;
					NODE r = q;
					while(1){
						NODE next = (*done[r.bit][r.pos]);
						if(next.pos == r.pos && next.bit == r.bit) break;
						if(r.pos != next.pos){
							stringstream ss;
							ss << "Move to room " << r.pos+1 <<".";
							a.push_back(ss.str());
						}else{
							diff(r.bit,next.bit,a);
						}
						r = next;
					}
					cout << "You can go home in " << a.size() << " steps." << endl;
					rep(i,a.size()){
						cout << a[a.size()-1-i] << endl;
					}
					goto exit;
				}
				flag = true;
			}
			rep(j,room[q.pos].size()){
				int nextbit = q.bit ^ room[q.pos][j];
				if(done[nextbit][q.pos] == NULL){
					done[nextbit][q.pos] = &Q[head];
					Q[size++] = NODE(q.pos,nextbit);
				}
			}
			rep(i,v[q.pos].size()){
				if(q.bit >> v[q.pos][i] & 1){
					if(done[q.bit][v[q.pos][i]] == NULL){
						done[q.bit][v[q.pos][i]] = &Q[head];
						Q[size++] = NODE(v[q.pos][i],q.bit);
					}
				}
			}
			head++;
		}
		if(flag)cout << "You can not switch off all lights." << endl;
		else cout << "Help me!" << endl;
		exit:;
	}
}