#include <queue>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	int N, M;
	while (cin >> N >> M, N) {
		vector<vector<int> > G(N);
		for (int i = 0; i < M; ++i) {
			int a, b;
			cin >> a >> b; --a, --b;
			G[a].push_back(b);
			G[b].push_back(a);
		}
		int inibit = 0;
		for (int i = 0; i < N; ++i) {
			int x;
			cin >> x;
			inibit |= x << i;
		}
		vector<int> op(N);
		for (int i = 0; i < N; ++i) {
			int c;
			cin >> c;
			for (int j = 0; j < c; ++j) {
				int x;
				cin >> x; --x;
				if (x != i) op[i] |= 1 << x;
			}
		}
		vector<vector<int> > dist(1 << N, vector<int>(N, -1));
		vector<vector<pair<int, int> > > pre(1 << N, vector<pair<int, int> >(N));
		queue<pair<int, int> > que;
		if (inibit & 1) {
			dist[inibit][0] = 0;
			que.push(make_pair(inibit, 0));
		}
		while (!que.empty()) {
			pair<int, int> u = que.front(); que.pop();
			int bit = u.first, pos = u.second;
			for (int i : G[pos]) {
				if (((bit >> i) & 1) && dist[bit][i] == -1) {
					dist[bit][i] = dist[bit][pos] + 1;
					pre[bit][i] = make_pair(bit, pos);
					que.push(make_pair(bit, i));
				}
			}
			for (int i = 0; i < N; ++i) {
				if (((op[pos] >> i) & 1) && dist[bit ^ (1 << i)][pos] == -1) {
					dist[bit ^ (1 << i)][pos] = dist[bit][pos] + 1;
					pre[bit ^ (1 << i)][pos] = make_pair(bit, pos);
					que.push(make_pair(bit ^ (1 << i), pos));
				}
			}
		}
		if (dist[1 << (N - 1)][N - 1] == -1) {
			bool escape = false;
			for (int i = 0; i < 1 << N; ++i) {
				if (dist[i][N - 1] != -1) {
					escape = true;
					break;
				}
			}
			cout << (escape ? "You can not switch off all lights." : "Help me!") << endl;
		}
		else {
			cout << "You can go home in " << dist[1 << (N - 1)][N - 1] << " steps." << endl;
			pair<int, int> cur = make_pair(1 << (N - 1), N - 1);
			vector<pair<int, int> > path = { cur };
			while (cur != make_pair(inibit, 0)) {
				cur = pre[cur.first][cur.second];
				path.push_back(cur);
			}
			reverse(path.begin(), path.end());
			vector<pair<string, int> > ans;
			for (int i = 1; i < path.size(); ++i) {
				if (path[i - 1].second != path[i].second) {
					ans.push_back(make_pair("move", path[i].second));
				}
				else {
					int diff = -1;
					for (int j = 0; j < N; ++j) {
						if (((path[i - 1].first >> j) & 1) != ((path[i].first >> j) & 1)) {
							diff = j;
							break;
						}
					}
					if ((path[i - 1].first >> diff) & 1) {
						ans.push_back(make_pair("off", diff));
					}
					else {
						ans.push_back(make_pair("on", diff));
					}
				}
			}
			for (int i = 0; i < ans.size(); ++i) {
				for (int j = 1; j < ans.size(); ++j) {
					if (ans[j - 1].first != "move" && ans[j].first != "move" && ans[j - 1].second > ans[j].second) {
						swap(ans[j - 1], ans[j]);
					}
				}
			}
			for (pair<string, int> i : ans) {
				if (i.first == "move") {
					cout << "Move to room " << i.second + 1 << "." << endl;
				}
				else if (i.first == "off") {
					cout << "Switch off room " << i.second + 1 << "." << endl;
				}
				else {
					cout << "Switch on room " << i.second + 1 << "." << endl;
				}
			}
		}
	}
	return 0;
}
