#include<iostream>
#include<queue>
#include<stack>

using namespace std;

#define rep(i, n) for (int i = 0; i < int(n); ++i)

typedef pair<int, pair<int ,int> > S;

int main() {
  while (true) {
    int n, m;
    cin >> n >> m;
    if (n == 0 && m == 0) break;
    vector<vector<int> > edge(n);
    rep (i, m) {
      int a, b;
      cin >> a >> b;
      a--; b--;
      edge[a].push_back(b);
      edge[b].push_back(a);
    }
    int bit = 0;
    rep (i, n) {
      int a;
      cin >> a;
      bit |= a << i;
    }
    vector<vector<int> > sw(n);
    rep (i, n) {
      int k;
      cin >> k;
      rep (j, k) {
	int r;
	cin >> r;
	--r;
	sw[i].push_back(r);
      }
    }
    queue<S> que;
    int dis[15][1 << 15];
    pair<int, int> pre[15][1 << 15];
    rep (i, n) rep (j, 1 << n) dis[i][j] = 1000000000;
    que.push(make_pair(0, make_pair(0, bit)));
    dis[0][bit] = 0;
    while (!que.empty()) {
      S now = que.front();
      que.pop();
      rep (i, edge[now.second.first].size()) {
	if (!(now.second.second & 1 << edge[now.second.first][i])) continue;
	S next;
	next.first = now.first + 1;
	next.second.first = edge[now.second.first][i];
	next.second.second = now.second.second;
	if (dis[next.second.first][next.second.second] <= next.first) continue;
	dis[next.second.first][next.second.second] = next.first;
	pre[next.second.first][next.second.second] = now.second;
	que.push(next);
      }
      rep (i, sw[now.second.first].size()) {
	S next;
	next.first = now.first + 1;
	next.second.first = now.second.first;
	next.second.second = now.second.second ^ 1 << sw[now.second.first][i];
	if (dis[next.second.first][next.second.second] <= next.first) continue;
	dis[next.second.first][next.second.second] = next.first;
	pre[next.second.first][next.second.second] = now.second;
	que.push(next);
      }
    }
    if (dis[n - 1][1 << (n - 1)] == 1000000000) {
      bool ok = false;
      rep (i, 1 << n) if (dis[n - 1][i] != 1000000000) ok = true;
      if (ok) cout << "You can not switch off all lights." << endl;
      else cout << "Help me!" << endl;
    } else {
      cout << "You can go home in " << dis[n - 1][1 << (n - 1)] << " steps." << endl;
      stack<pair<int, int> > st;
      pair<int, int> now = make_pair(n - 1, 1 << (n - 1));
      st.push(now);
      while (now.first != 0 || now.second != bit) {
	now = pre[now.first][now.second];
	st.push(now);
      }
      pair<int, int> q = st.top();
      st.pop();
      while (!st.empty()) {
	pair<int, int> p = st.top();
	st.pop();
	if (p.first == q.first) {
	  int b = p.second ^ q.second;
	  if (b & p.second) {
	    cout << "Switch on room " << __builtin_ffs(b) << "." << endl;
	  } else {
	    cout << "Switch off room " << __builtin_ffs(b) << "." << endl;
	  }
	} else {
	  cout << "Move to room " << p.first + 1 << "." << endl;
	}
	q = p;
      }
    }
  }
  return 0;
}