#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <utility>
#include <algorithm>
using namespace std;

typedef pair<int,int> pii;

bool visit[1 << 20];
int prev[1 << 20];

void output(int n, int x){
	printf("You can go home in %d steps.\n", x);

	vector<int> v;
	v.push_back(n << 16 | 1 << n);
	while(prev[v.back()] != -1){
		v.push_back(prev[v.back()]);
	}

	for(int i = v.size() - 1; i > 0; --i){
		int now = v[i], next = v[i-1];
		if((now >> 16) != (next >> 16)){
			printf("Move to room %d.\n", next >> 16);
		}
		else{
			for(int j = 1; j <= n; ++j){
				if((now ^ next) >> j & 1){
					if(now >> j & 1){
						printf("Switch off room %d.\n", j);
					}
					else{
						printf("Switch on room %d.\n", j);
					}
				}
			}
		}
	}
}

int solve(int n, int m){
	memset(visit, 0, sizeof visit);
	memset(prev, -1, sizeof prev);

	vector<vector<int> > G(n + 1), sw(n + 1);
	int s, t;
	for(int i = 0; i < m; ++i){
		scanf("%d%d", &s, &t);
		G[s].push_back(t);
		G[t].push_back(s);
	}

	int state = 1 << 16;
	for(int i = 1; i <= n; ++i){
		scanf("%d", &s);
		state |= s << i;
	}
	
	for(int i = 1; i <= n; ++i){
		scanf("%d", &s);
		sw[i].resize(s);
		for(int j = 0; j < s; ++j){
			scanf("%d", &sw[i][j]);
		}
		sort(sw[i].begin(), sw[i].end());
	}

	if(!(state & 2)){ return 2; }

	int goal = n << 16 | 1 << n;

	queue<int> q;
	q.push(state);
	q.push(-1);
	
	visit[state] = true;
	int result = 2;
	int x = 0;
	while(q.size() > 1){
		state = q.front();
		q.pop();
		
		if(state == -1){
			q.push(-1);
			++x;
		}
		else{
			if(state == goal){
				output(n, x);
				return 0;
			}

			int room = state >> 16;
			if(room == n){
				result = 1;
			}

			for(int i = 0; i < G[room].size(); ++i){
				int to = G[room][i];
				int next = state & 0xffff | to << 16;
				if(state >> to & 1 && !visit[next]){
					visit[next] = true;
					prev[next] = state;
					q.push(next);
				}
			}

			for(int i = 0; i < sw[room].size(); ++i){
				int next = state ^ (1 << sw[room][i]);
				if(sw[room][i] != room && !visit[next]){
					visit[next] = true;
					prev[next] = state;
					q.push(next);
				}
			}
		}
	}
	
	return result;
}

int main(){
	int n, m;
	while(scanf("%d%d", &n, &m), n){
		int res = solve(n, m);
		if(res == 1){
			puts("You can not switch off all lights.");
		}
		else if(res == 2){
			puts("Help me!");
		}
	}
}