#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <cstring>
#include <deque>
#include <cstdio>
#include <cmath>
#include <complex>
#include <iostream>
#include <iterator>

using namespace std;

#define reep(i,f,t) for(int i=f ; i<int(t) ; ++i)
#define rep(i,n) reep(i, 0, n) 

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int main()
{
	int n, m;
	while(scanf("%d%d", &n, &m), n){
		vvi door(n);
		rep(i, m){
			int s, t;
			scanf("%d%d", &s, &t);
			--s;
			--t;
			door[s].push_back(t);
			door[t].push_back(s);
		}
		
		int mask = 0;
		rep(i, n){
			int a;
			scanf("%d", &a);
			mask |= a<<i;
		}
		
		vvi sw(n);
		rep(i, n){
			int k;
			scanf("%d", &k);
			sw[i].assign(k, 0);
			rep(j, k){
				int r;
				scanf("%d", &r);
				sw[i][j] = r - 1;
			}
			sort(sw[i].begin(), sw[i].end());
		}
		
		vector<vector<bool> > visited(1<<n, vector<bool>(n, false));
		vector<vector<pii> > pre(1<<n, vector<pii>(n, pii(-1, 0)));
		queue<pii> Q;
		pii first(mask, 0);
		visited[first.first][first.second] = true;
		Q.push(first);
		while(!Q.empty()){
			pii data = Q.front();
			Q.pop();
			rep(i, door[data.second].size()){
				if(data.first & (1 << door[data.second][i])){
					pii next(data.first, door[data.second][i]);
					if(!visited[next.first][next.second]){
						visited[next.first][next.second] = true;
						pre[next.first][next.second] = data;
						Q.push(next);
					}
				}
			}
			
			rep(i, sw[data.second].size()){
				if(data.second == sw[data.second][i])
					continue;
				pii next(data.first ^ (1 << sw[data.second][i]), data.second);
				if(!visited[next.first][next.second]){
					visited[next.first][next.second] = true;
					pre[next.first][next.second] = data;
					Q.push(next);
				}
			}
		}
		
		pii goal(1<<(n-1), n-1);
		if(visited[goal.first][goal.second]){
			vector<pii> way;
			for(pii now = goal; now.first != -1; now = pre[now.first][now.second])
				way.push_back(now);
			
			reverse(way.begin(), way.end());
			printf("You can go home in %d steps.\n", way.size()-1);
			
			reep(i, 1, way.size()){
				if(way[i].second != way[i-1].second){
					printf("Move to room %d.\n", way[i].second+1);
				}else{
					int diff = way[i].first ^ way[i-1].first;
					rep(j, n){
						if(diff == 1<<j){
							printf("Switch %s room %d.\n", (way[i].first & diff) ? "on" : "off", j+1);
							break;
						}
					}
				}
			}
		}else{
			bool found = false;
			rep(i, 1<<n){
				if(visited[i][n-1]){
					found = true;
					break;
				}
			}
			puts(found ? "You can not switch off all lights." : "Help me!");
		}
	}
	return 0;
}