#include <iostream>
#include <stack>
#include <cstdlib>
using namespace std;

const int ROOM_NUM = 15;
int tab[1 << ROOM_NUM][ROOM_NUM];
pair<int,int> from[1 << ROOM_NUM][ROOM_NUM];

int n, m;
int door[ROOM_NUM][ROOM_NUM];
int switches[ROOM_NUM];

const int INF = 1e9;

int bitDP(const int lights, const int doctor) {
	if(tab[lights][doctor] + 1) {
		return tab[lights][doctor];
	}

	int & res = tab[lights][doctor];
	res = INF;
	// light operation
	for(int i = 0; i < n; i++) {
		if((switches[doctor] & (1 << i)) && i != doctor) {
			int tmp = bitDP(lights ^ (1 << i), doctor) + 1;
			if(res > tmp) {
				res = tmp;
				from[lights][doctor] = pair<int,int>(lights ^ (1 << i), doctor);
			}
		}
	}
	// move
	for(int i = 0; i < n; i++) {
		if(door[doctor][i] == 1 && (lights & (1 << i)) && i != doctor) {
			int tmp = bitDP(lights, i) + 1;
			if(res > tmp) {
				res = tmp;
				from[lights][doctor] = pair<int,int>(lights, i);
			}
		}
	}
	return res;
}

int main() {
	while(cin >> n >> m, n || m) {
		// init
		for(int i = 0; i < (1 << ROOM_NUM); i++) {
			for(int j = 0; j < ROOM_NUM; j++) {
				tab[i][j] = -1;
				from[i][j] = pair<int,int>(-1, -1);
			}
		}
		for(int i = 0; i < ROOM_NUM; i++) {
			for(int j = 0; j < ROOM_NUM; j++)
				door[i][j] = 0;
			switches[i] = 0;
		}
		// input
		for(int i = 0; i < m; i++) {
			int s, t;
			cin >> s >> t;
			door[s - 1][t - 1] = 1;
			door[t - 1][s - 1] = 1;
		}

		int lightstatus = 0;
		for(int i = 0; i < n; i++) {
			int tmp;
			cin >> tmp;
			lightstatus |= tmp << i;
		}
		for(int i = 0; i < n; i++) {
			int k;
			cin >> k;
			for(int j = 0; j < k; j++) {
				int tmp;
				cin >> tmp;
				switches[i] |= 1 << (tmp - 1);
			}
		}

		tab[lightstatus][0] = 0;

		if(bitDP(1 << (n - 1), n - 1) < INF) {
			stack<pair<int,int> > path;
			pair<int,int> tmp(1 << (n - 1), n - 1);
			while(tmp != pair<int,int>(lightstatus,0)) {
				path.push(tmp);
				tmp = from[tmp.first][tmp.second];
				if(tmp == pair<int,int>(-1,-1))
					abort();
			}

			cout << "You can go home in " << bitDP(1 << (n - 1), n - 1) << " steps." << endl;;

			while(!path.empty()) {
				pair<int,int> t;
				t = path.top(); path.pop();
				if(t.second != tmp.second)
					cout << "Move to room " << t.second + 1 << "." << endl;
				else {
					int r;
					for(int i = 0; i < n; i++) {
						if((t.first ^ tmp.first) & (1 << i))
							r = i;
					}
					if(tmp.first & (1 << r))
						cout << "Switch off room " << r + 1 << "." << endl;
					else
						cout << "Switch on room " << r + 1 << "." << endl;
				}

				tmp = t;
			}
		}
		else {
			bool flg = false;
			for(int i = 0; i < (1 << n); i++) {
				if((i & (1 << (n - 1))) && bitDP(i, n - 1) < INF) {
					flg = true;
					break;
				}
			}
			if(flg)
				cout << "You can not switch off all lights." << endl;
			else
				cout << "Help me!" << endl;
		}
	}
}