// AOJ 0172: Doctor's Research Rooms
// 2018.1.24 bal4u@uu

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MOVE 0x40
#define ON   0x50
#define OFF  0x60

#define QMAX 300000
typedef struct { char rm; int light; char step, act[50]; } Q;
Q q[QMAX+2]; int top, end;

int rm[15][15], s_rm[15];
int sw[15][15], s_sw[15];
char mk[15][33000];

char *msg[7] = {0,
"You can go home in %d steps.\n",
"You can not switch off all lights.",
"Help me!",
"Move to room %d.\n",
"Switch on room %d.\n",
"Switch off room %d.\n" };

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	while (c < '0') c = getchar_unlocked();
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

int cmp(int *a, int *b) { return *a - *b; }

int main()
{
	int n, m, i, j, s, t, ans;
	int light;
	Q p, np;

	while (n = in()) {
		m = in();
		memset(s_rm, 0, sizeof(s_rm));
		memset(s_sw, 0, sizeof(s_sw));

		for (i = 0; i < m; i++){
			s = in()-1, t = in()-1;
			rm[s][s_rm[s]++] = t;
			rm[t][s_rm[t]++] = s;
		}

		light = 0; for (i = 0; i < n; i++) if (in()) light |= 1 << i;

		for (i = 0; i < n; i++) {
			j = in(); while (j--) sw[i][s_sw[i]++] = in()-1;
			qsort(sw[i], s_sw[i], sizeof(int), cmp);
        }

		memset(mk, 0, sizeof(mk));
		q[0].rm = 0, q[0].light = light, q[0].step = 0;
		top = 0, end = 1;
		ans = 3;

		while (top != end) {
			p = q[top]; if (++top == QMAX) top = 0;
			s = p.rm, t = p.light;

			if (mk[s][t]) continue;
			mk[s][t] = 1;
			if (s == n-1) {
				if (t == 1<<(n-1)) { ans = 1; break; }
				ans = 2;
			}

			for (i = 0; i < s_sw[s]; i++) if (sw[s][i] != s) {
				j = t ^ (1<<sw[s][i]);
				np = p, np.light = j;
				if (t & (1<<sw[s][i])) np.act[np.step] = OFF | sw[s][i];
				else 				   np.act[np.step] = ON  | sw[s][i];
				np.step++;
				q[end] = np; if (++end == QMAX) end = 0;
			}

			for (i = 0; i < s_rm[s]; i++) if (t & (1<<rm[s][i])) {
				np = p, np.rm = rm[s][i];
				np.act[np.step++] = MOVE | rm[s][i];
				q[end] = np; if (++end == QMAX) end = 0;
			}
		}
 
		if (ans > 1) puts(msg[ans]);
		else {
			printf(msg[ans], p.step);
			for (i = 0; i < p.step; i++) printf(msg[p.act[i] >> 4], 1+(p.act[i] & 0xf));
		}
    }
    return 0;
}
