#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

struct action {
	int type;
	int num;
};
struct room {
	vector<int>edges;
	vector<int>switches;
	room():edges(), switches(){
	}
};
vector<action> memo[1 << 15][15];
int N, M;
bool cangoal = false;

struct aa {
	int now;
	bitset<15>lights;
	int time;
};
class Compare {
public:
	bool operator ()(const aa&l, const aa&r) {
		return  l.time > r.time;
	}
};

int main() {
	while (1) {
		
		queue<aa>que;
		cin >> N >> M;
		if (!N)break;
		vector<room>rooms(N);
		{
			cangoal = false;
			for (int i = 0; i < (1 << 15); ++i) {
				for (int j = 0; j < 15; ++j) {
					memo[i][j] = vector<action>();
				}
			}
			
			for (int i = 0; i < M; ++i) {
				int s, t; cin >> s >> t;
				s--; t--;
				rooms[s].edges.push_back(t);
				rooms[t].edges.push_back(s);
			}
			bitset<15>lights;
			for (int i = 0; i < N; ++i) {
				int l; cin >> l;
				lights[i] = l;
			}
			for (int i = 0; i < N; ++i) {
				int k; cin >> k;
				for (int j = 0; j < k; ++j) {
					int r; cin >> r;
					r--;
					rooms[i].switches.push_back(r);
				}
				sort(rooms[i].switches.begin(), rooms[i].switches.end());
			}
			que.push(aa{ 0,lights,0 });
		}
		vector<action>ans;
		while (!que.empty()) {
			aa atop(que.front());
			que.pop();
			if (atop.now == N - 1) {
				cangoal = true;
				if (atop.lights.count() == 1) {
					ans = memo[atop.lights.to_ulong()][atop.now];
					break;
				}
			}
			for (auto next : rooms[atop.now].edges) {
				if (atop.lights[next]) {
					if (memo[atop.lights.to_ulong()][next].empty()) {
						memo[atop.lights.to_ulong()][next] = memo[atop.lights.to_ulong()][atop.now];
						memo[atop.lights.to_ulong()][next].push_back(action{ 2,1 + next });
						que.push(aa{ next,atop.lights,atop.time+1 });
					}
				}
			}
			for (auto sw : rooms[atop.now].switches) {
				bitset<15>nextlights(atop.lights);
				nextlights[sw] = !atop.lights[sw];
				if (memo[nextlights.to_ulong()][atop.now].empty()) {
					memo[nextlights.to_ulong()][atop.now] = memo[atop.lights.to_ulong()][atop.now];
					memo[nextlights.to_ulong()][atop.now].push_back(action{ !nextlights[sw],sw+1 });
					que.push(aa{ atop.now,nextlights,atop.time + 1 });
				}
			}
		}
		if (ans.empty()) {
			if (cangoal) {
				cout << "You can not switch off all lights." << endl;
			}
			else {
				cout << "Help me!" << endl;
			}
		}
		else {
			cout << "You can go home in " <<ans.size() << " steps." << endl;
			for (auto a : ans) {
				if (a.type == 0) {
					cout << "Switch on room " << a.num << "." << endl;
				}
				else if (a.type == 1) {
					cout << "Switch off room " << a.num <<"." << endl;
				}
				else {
					cout << "Move to room " << a.num << " " << endl;
				}
			}
		}
	}
	return 0;
}