#include<iostream>
#include<queue>
#include<cassert>
#include<sstream>

using namespace std;

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

struct S {
  int pos, bit;
  vector<string> ans;
};

bool used[15][1 << 15];

int main() {
  while (true) {
    int n, m, s, t, bit = 0;
    cin >> n >> m;
    if (n == 0 && m == 0) break;
    vector<vector<int> > e(n), sw(n);
    rep (i, m) {
      cin >> s >> t;
      --s, --t;
      e[s].push_back(t);
      e[t].push_back(s);
    }
    rep (i, n) {
      cin >> s;
      bit |= s << i;
    }
    rep (i, n) {
      cin >> s;
      rep (j, s) {
	cin >> t;
	sw[i].push_back(t - 1);
      }
    }
    assert(bit & 1);
    queue<S> que;
    S ss;
    ss.pos = 0;
    ss.bit = bit;
    que.push(ss);
    rep (i, n) rep (j, 1 << n) used[i][j] = false;
    bool f1 = false, f2 = false;
    while (!que.empty()) {
      S now = que.front();
      que.pop();
      if (used[now.pos][now.bit]) continue;
      used[now.pos][now.bit] = true;
      if (now.pos == n - 1) {
	f1 = true;
	if (now.bit == (1 << (n - 1))) {
	  f2 = true;
	  stringstream ss;
	  ss << now.ans.size();
	  string str;
	  ss >> str;
	  cout << "You can go home in " + str + " steps." << endl;
	  rep (i, now.ans.size()) cout << now.ans[i] << endl;
	  break;
	}
      } 
      rep (i, e[now.pos].size()) {
	if (!(now.bit & 1 << e[now.pos][i])) continue;
	S next = now;
	next.pos = e[now.pos][i];
	stringstream ss;
	ss << next.pos + 1;
	string str;
	ss >> str;
	next.ans.push_back("Move to room " + str + ".");
	que.push(next);
      }
      rep (i, sw[now.pos].size()) {
	S next = now;
	next.bit = now.bit ^ 1 << sw[now.pos][i];
	stringstream ss;
	ss << sw[now.pos][i] + 1;
	string str;
	ss >> str;
	if (next.bit & 1 << sw[now.pos][i]) {
	  next.ans.push_back("Switch on room " + str + ".");
	} else {
	  next.ans.push_back("Switch off room " + str + ".");
	}
	que.push(next);
      }
    }
    if (!f1) {
      cout << "Help me!" << endl;
    } else if (!f2) {
      cout << "You can not switch off all lights." << endl;
    }
  }
  return 0;
}