#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

#define lengthof(array) (sizeof(array) / sizeof(*array))
#define dump(a) (cerr << (#a) << " = " << (a) << endl)
#define FOR(it,c) for(__typeof((c).begin())it=(c).begin(); it!=(c).end();++it)
#define RFOR(it,c) for(__typeof((c).rbegin())it=(c).rbegin(); it!=(c).rend();++it)

template<class T> inline void chmax(T& a, const T& b) { if(b > a) a = b; }
template<class T> inline void chmin(T& a, const T& b) { if(b < a) a = b; }

template<typename T, typename U> ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os << '(' << p.first << ", " << p.second << ')';
	return os;
}

template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	copy(v.begin(), v.end(), ostream_iterator<T>(os, " "));
	return os;
}

struct state {
	int room, light, step;
	state(int r, int l, int s):room(r), light(l), step(s){}
};

const int CANNOT = -1;
const int HELP = -2;

int n, m;
int goal;
vector<vector<int> > es;
vector<vector<int> > switches;
vector<vector<pair<int, int> > > prev;

int bfs(int s, int t, int light) {
	vector<vector<bool> > visited(n, vector<bool>((1 << n), false));
	visited[s][light] = true;
	prev.clear();
	prev.resize(n, vector<pair<int, int> >((1 << n), make_pair(-1, -1)));
	queue<state> que;
	que.push(state(s, light, 0));

	bool reachable = false;
	
	while(!que.empty()) {
		const state s = que.front();
		que.pop();

		if(s.room == t) {
			if(s.light == goal)
				return s.step;

			reachable = true;
		}

		for(int i = 0; i < es[s.room].size(); ++i) {
			const int to = es[s.room][i];
			if(!visited[to][s.light] && ((s.light >> to) & 1)) {
				visited[to][s.light] = true;
				que.push(state(to, s.light, s.step + 1));
				prev[to][s.light] = make_pair(s.room, s.light);
			}
		}

		for(int i = 0; i < switches[s.room].size(); ++i) {
			const int next_light = s.light ^ (1 << switches[s.room][i]);
			if(!visited[s.room][next_light]) {
				visited[s.room][next_light] = true;
				que.push(state(s.room, next_light, s.step + 1));
				prev[s.room][next_light] = make_pair(s.room, s.light);
			}
		}
	}

	if(reachable)
		return CANNOT;

	return HELP;
}

vector<pair<int, int> > get_path(int t){
	vector<pair<int, int> > path;
	pair<int, int> cur;
	for(pair<int, int> cur(t, goal); cur.first != -1; cur = prev[cur.first][cur.second])
		path.push_back(cur);

	reverse(path.begin(),path.end());
	return path;	
}


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

	while(cin >> n >> m, n) {
		goal = (1 << (n - 1));
		es.clear();
		es.resize(n);
		for(int i = 0; i < m; ++i) {
			int s, t;
			cin >> s >> t;
			es[s - 1].push_back(t - 1);
			es[t - 1].push_back(s - 1);
		}

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

		switches.clear();
		switches.resize(n);
		for(int i = 0; i < n; ++i) {
			int k;
			cin >> k;

			for(int j = 0; j < k; ++j) {
				int r;
				cin >> r;
				if(r - 1 != i)
					switches[i].push_back(r - 1);
			}

			sort(switches[i].begin(), switches[i].end());
		}

		if(!(light & 1)) {
			cout << "Help me!" << endl;
			continue;
		}

		int result = bfs(0, n - 1, light);
		if(result == CANNOT)
			cout << "You can not switch off all lights." << endl;

		else if(result == HELP)
			cout << "Help me!" << endl;

		else {
			cout << "You can go home in " << result << " steps." << endl;
			vector<pair<int, int> > path = get_path(n - 1);
			for(int i = 0; i < result; ++i) {
				if(path[i].first != path[i + 1].first)
					cout << "Move to room " << path[i + 1].first + 1 << "." << endl;

				else {
					int room = __builtin_ctz(path[i].second ^ path[i + 1].second) + 1;
					if(path[i].second > path[i + 1].second)
						cout << "Switch off room " << room << "." << endl;
					else
						cout << "Switch on room " << room << "." << endl;
				}
			}
		}
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 5652