#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

const int INF = 1 << 25;
int dp[15][1 << 15];
P pre[15][1 << 15];
const int MOVE = 0;
const int ON = 1;
const int OFF = 2;

struct state {
	int v, s, d;
};

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int n, m;
	while(cin >> n >> m, n + m) {
		vector<int> G[15];
		for(int i = 0; i < m; i++) {
			int s, t;
			cin >> s >> t;
			s--, t--;
			G[s].push_back(t);
			G[t].push_back(s);
		}

		int is = 0;
		for(int i = 0; i < n; i++) {
			int l;
			cin >> l;
			if(l) is |= 1 << i;
		}

		vector<int> sw[15];
		for(int i = 0; i < n; i++) {
			int k, r;
			cin >> k;
			while(k--) {
				cin >> r;
				r--;
				sw[i].push_back(r);
			}
		}

		fill((int*)begin(dp), (int*)end(dp), INF);
		dp[0][is] = 0;
		queue<state> q;
		q.push({ 0, is, 0 });
		while(q.size()) {
			int v = q.front().v, s = q.front().s, d = q.front().d;
			q.pop();
			if(dp[v][s] < d) continue;
			//cout << d << endl;
			// move
			for(auto u : G[v]) {
				if((s >> u & 1) && dp[u][s] > d + 1) {
					dp[u][s] = d + 1;
					pre[u][s] = { v, MOVE };
					q.push({ u, s, d + 1 });
				}
			}
			// switch
			for(auto t : sw[v]) {
				int ns = s ^ (1 << t);
				if(dp[v][ns] > d + 1) {
					dp[v][ns] = d + 1;
					if(s >> t & 1) pre[v][ns] = { t, OFF };
					else pre[v][ns] = { t, ON };
					q.push({ v, ns, d + 1 });
				}
			}
		}

		if(dp[n - 1][1 << (n - 1)] != INF) {
			int v = n - 1, s = 1 << (n - 1);
			vector<P> ans, tmp;
			while(!(v == 0 && s == is)) {
				//cout << v << " " << s << endl;
				if(pre[v][s].second == MOVE) {
					sort(tmp.begin(), tmp.end());
					reverse(tmp.begin(), tmp.end());
					for(auto p : tmp) {
						ans.push_back(p);
					}
					tmp.clear();
					ans.push_back({ v, MOVE });
					v = pre[v][s].first;
				}
				else {
					tmp.push_back(pre[v][s]);
					s ^= 1 << pre[v][s].first;
				}
			}
			sort(tmp.begin(), tmp.end());
			reverse(tmp.begin(), tmp.end());
			for(auto p : tmp) {
				ans.push_back(p);
			}

			reverse(ans.begin(), ans.end());
			cout << "You can go home in " << ans.size() << " steps." << endl;
			for(auto p : ans) {
				if(p.second == MOVE) {
					cout << "Move to room " << p.first + 1 << "." << endl;
				}
				else if(p.second == ON) {
					cout << "Switch on room " << p.first + 1 << "." << endl;
				}
				else {
					cout << "Switch off room " << p.first + 1 << "." << endl;
				}
			}
		}
		else {
			bool ok = false;
			for(int i = 0; i < 1 << n; i++) {
				if(dp[n - 1][i] != INF) {
					cout << "You can not switch off all lights." << endl;
					ok = true;
					break;
				}
			}
			if(!ok) {
				cout << "Help me!" << endl;
			}
		}
	}
}