# 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;
typedef vector<pii> vp;
int n, m;
vi d[16];
vi sw[16];
map<pii, vp> al;
void calc(int bit, int now, vp &a)
{
	if (!(bit & 1 << now))return;
	if (al.count(pii(bit, now))&&al[pii(bit,now)].size()<a.size())return;
	al[pii(bit, now)] = a;

	FOR(i, d[now].size())//move
	{
		int nbit = bit;
		int nnow = d[now][i];
		vp na = a;
		na.push_back(pii(MOVE, nnow));
		calc(nbit, nnow, na);
	}

	FOR(i, sw[now].size())//switch
	{
		int nbit = bit ^ (1 << sw[now][i]);
		int nnow = now;
		vp na = a;
		na.push_back(pii((bit & 1 << sw[now][i]) ? OFF : ON, sw[now][i]));
		calc(nbit, nnow, na);
	}
}


int main()
{
	while (cin >> n >> m&&n)
	{
		FOR(i, 16)
		{
			d[i].clear();
			sw[i].clear();
		}
		al.clear();
		FOR(i, m)
		{
			int s, t; cin >> s >> t;
			d[s].push_back(t);
			d[t].push_back(s);
		}
		int start = 0;
		vi ss;
		FOR(i, n)
		{
			INT(b);
			ss.push_back(b);

		}
		reverse(ALL(ss));
		FOR(i, n)
		{
			start |= ss[i];
			start <<= 1;
		}
		FOR(i, n)
		{
			INT(k);
			FOR(j, k)
			{
				INT(x);
				sw[i + 1].push_back(x);
			}
			sort(sw[i + 1].rbegin(), sw[i + 1].rend());
		}
		vp v;
		calc(start, 1, v);
		int mn = 0;
		bool ok = false;
		for (auto i : al)
		{
			mn = max(mn, i.first.second);
			if (i.first == pii(1 << n, n))
			{
				ok = true;
				printf("You can go home in %d steps.\n", i.second.size());
				vp ans = i.second;
				for (auto p : ans)
				{
					switch (p.first)
					{
					case MOVE:
						printf("Move to room %d.\n",p.second);
						break;
					case ON:
						printf("Switch on room %d.\n", p.second);
						break;
					case OFF:
						printf("Switch off room %d.\n", p.second);
						break;
					}
				}
				break;
			}
		}
		if (!ok) 
		{
			if (mn == n)
			{
				cout << "You can not switch off all lights." << endl;
			}
			else
			{
				cout << "Help me!" << endl;
			}
		}

	}
}