# define _CRT_SECUREj_NO_WARNINGS 1
# define _USE_MATH_DEFINES
# include <iostream>
# include <numeric>
# include <string>
# include <bitset>
# include <vector>
# include <algorithm>
# include <cstdlib>
# include <cstdio>
# include <cstring>
# include <cstdlib>
# include <iomanip>
# include <queue>
# include <sstream>
# include <climits>
# include <cmath>
# include <list>
# include <functional>
# include <string>
# include <ctime>
# include <set>
# include <forward_list>
# include <map>
# include <stack>
using namespace std;
# define INF ((int)(1<<25))
# define REP(i,n) for(int i=0;i<(int)n;i++)
# define FOR(i,n) REP(i,n)
# define TORAD 2.0*M_PI/360.0
# define INT(x) int x;cin>>x;
# define ALL(x) (x).begin(),(x).end()
# define RALL(x) (x).rbegin(),(x).rend()
# define DEBUG(x) cout<<#x<<" :"<<x<<endl;
# define EPS 1e-12
#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#endif
typedef long long lint;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
const int dx[4] = { 0,1,0,-1 }, dy[4] = { -1,0,1,0 };
template<class T> void debug(T a) { for (auto i : a)cout << i << endl; }

const int MOVE = 0, ON = 1, OFF = 2;
int n, m;
vi d[20];
vi sw[20];
pii pre[1 << 16][20];
pii pw[1 << 16][20];
struct P
{
	int a = 0;
	int bit = 0, now = 0;

	bool operator<(const P r)const
	{
		return a < r.a;
	}
	bool operator>(const P r)const
	{
		return a > r.a;
	}
};
bool ls(const pii& l, const pii& r)
{
	return l.second < r.second;
}
int main()
{
	while (cin >> n >> m&&n)
	{
		FOR(i, 20)
		{
			d[i].clear();
			sw[i].clear();
		}
		FOR(i, 1 << 16)  FOR(j, 20)pre[i][j] = pw[i][j] = pii(-1, -1);

		FOR(i, m)
		{
			int s, t; cin >> s >> t;
			d[s].push_back(t);
			d[t].push_back(s);
		}
		P start;
		vi ss;
		FOR(i, n)
		{
			INT(b);
			ss.push_back(b);
		}
		reverse(ALL(ss));
		FOR(i, n)
		{
			start.bit |= ss[i];
			start.bit <<= 1;
		}
		start.now = 1;
		FOR(i, n)
		{
			INT(k);
			FOR(j, k)
			{
				INT(x);
				sw[i + 1].push_back(x);
			}
			sort(ALL(sw[i + 1]));
		}
		priority_queue< P, vector<P>, greater<P> >que;
		que.push(start);
		bool ok = false;
		while (!que.empty())
		{
			P now = que.top(); que.pop();
			if (now.now == n)ok = true;
			FOR(i, d[now.now].size())
			{
				if (!(now.bit & 1 << d[now.now][i]))continue;
				P next = now;
				next.a++;
				next.now = d[now.now][i];
				if (pre[next.bit][next.now] == pii(-1, -1))
				{
					que.push(next);
					pre[next.bit][next.now] = pii(now.bit, now.now);
					pw[next.bit][next.now] = pii(MOVE, next.now);
				}
			}
			FOR(i, sw[now.now].size())
			{
				if (now.now == sw[now.now][i])continue;
				P next = now;
				next.a++;
				next.bit ^= 1 << sw[now.now][i];

				if (pre[next.bit][next.now] == pii(-1, -1))
				{
					que.push(next);
					pre[next.bit][next.now] = pii(now.bit, now.now);
					pw[next.bit][next.now] = pii(now.bit & 1 << sw[now.now][i] ? OFF : ON, sw[now.now][i]);
				}
			}

		}
		vector<pii> ans;
		if (ok)
		{
			if (pre[1 << n][n] != pii(-1, -1))
			{
				pii now(1 << n, n);
				while (now.first != start.bit || now.second != 1)
				{
					ans.push_back(pw[now.first][now.second]);
					now = pre[now.first][now.second];
				}
				reverse(ALL(ans));
				for (int i = 0; i < ans.size(); i++)
				{
					int l, r;
					if (ans[i].first == ON || ans[i].first == OFF)
					{
						r = l = i;
						while (ans[r].first == ON || ans[r].first == OFF)
						{
							r++;
							if (r == ans.size())break;
						}
						sort(ans.begin() + l, ans.begin() + r, ls);
					}
				}

				printf("You can go home in %d steps.\n", ans.size());
				FOR(i, ans.size())
				{
					switch (ans[i].first)
					{
					case MOVE:
						printf("Move to room %d.\n", ans[i].second);
						break;
					case OFF:
						printf("Switch off room %d.\n", ans[i].second);
						break;
					case ON:
						printf("Switch on room %d.\n", ans[i].second);
						break;
					}
				}
			}
			else
			{
				cout << "You can not switch off all lights." << endl;
			}
		}
		else
		{
			cout << "Help me!" << endl;
		}

	}
}