#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>

using namespace std;

const int INF = 100000000;
const int N = 16;

class State{
public:
  int pos, light, cost;
};

int n, m;
vector<int> r[N];
vector<int> G[N];
int l;
vector<pair<int, int> > path;
int memo[N][(1<<N)];
pair<int, int> p[N][(1<<N)];

void add_edge(int a, int b){
  G[a].push_back(b);
  G[b].push_back(a);
}

int solve(){
  fill(memo[0], memo[N], INF);
  memo[0][l] = 0;
  State u, v;
  u.light = l;
  u.pos = 0;
  u.cost = 0;
  fill(p[0], p[N], make_pair(-1, -1));
  queue<State> Q;
  Q.push(u);
  while(!Q.empty()){
    u = Q.front(); Q.pop();
    for(int i=0;i<G[u.pos].size();i++){
      v.pos = G[u.pos][i];
      v.light = u.light;
      v.cost = u.cost + 1;
      if(!(1<<v.pos & v.light)) continue;
      if(memo[v.pos][v.light] <= v.cost) continue;
      memo[v.pos][v.light] = v.cost;
      p[v.pos][v.light] = make_pair(0, u.pos);
      Q.push(v);
    }
    for(int i=0;i<r[u.pos].size();i++){
      v.pos = u.pos;
      v.cost = u.cost + 1;
      int idx = r[u.pos][i];
      int f;
      if(1<<idx & u.light && idx != u.pos){
	v.light = u.light & ~(1<<idx);
	f = 2;
      }else{
	v.light = u.light | 1<<idx;
	f = 1;
      }
      if(memo[v.pos][v.light] <= v.cost) continue;
      memo[v.pos][v.light] = v.cost;
      p[v.pos][v.light] = make_pair(f, idx);
      Q.push(v);
    }
  }
  if(memo[n-1][1<<(n-1)] == 0) return 0;
  if(memo[n-1][1<<(n-1)] < INF){
    path.clear();
    int pos = n-1, light = 1<<(n-1);
    while(1){
      pair<int, int> tmp = p[pos][light];
      if(tmp.first <= -1 && tmp.second <= -1){
	break;
      }
      if(tmp.first == 0){
	path.push_back(make_pair(0, pos));
	pos = tmp.second;
      }else if(tmp.first == 1){
	path.push_back(tmp);
	light = light & ~(1<<tmp.second);
      }else if(tmp.first == 2){
	path.push_back(tmp);
	light = light | 1<<tmp.second;
      }
    }
    reverse(path.begin(), path.end());
    return memo[n-1][1<<(n-1)];
  }
  for(int i=0;i<(1<<n);i++){
    if(memo[n-1][i] != INF) return -1;
  }
  return -2;
}

main(){
  while(cin >> n >> m){
    if(n<1) break;
    if(m<1) break;
    if(n>15) break;
    if(m>30) break;
    for(int i=0;i<N;i++){
      r[i].clear();
      G[i].clear();
    }
    for(int i=0;i<m;i++){
      int a, b;
      cin >> a >> b;
      add_edge(a-1, b-1);
    }
    l = 0;
    for(int i=0;i<n;i++){
      int a;
      cin >> a;
      if(!a) continue;
      l |= (1<<i);
    }
    for(int i=0;i<n;i++){
      int k;
      cin >> k;
      for(int j=0;j<k;j++){
	int a;
	cin >> a;
	r[i].push_back(a-1);
      }
    }
    int ans = solve();
    if(ans == -2){
      cout << "Help me!" << endl;
    }else if(ans == -1){
      cout << "You can not switch off all lights." << endl;
    }else if(ans == 0){
      cout << "You can go home in " << ans << " steps." << endl;
    }else{
      cout << "You can go home in " << ans << " steps." << endl;
      for(int i=0;i<path.size();i++){
	switch(path[i].first){
	case 0:
	  cout << "Move to ";
	  break;
	case 1:
	  cout << "Switch on ";
	  break;
	case 2:
	  cout << "Switch off ";
	  break;
	}
	cout << "room " << path[i].second+1 << "." << endl;
      }
    }
  }
  return 0;
}