#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int main(){
  int N, M;
  while(cin >> N >> M && N){
    vector<int> G[16];
    vector<int> sw[16];
    REP(i, M) {
      int x, y;
      cin >> x >> y;
      G[x - 1].push_back(y - 1);
      G[y - 1].push_back(x - 1);
    }
    int start = 0;
    REP(i, N){
      int t; cin >> t;
      if(t == 1) start |= 1 << i;
    }
    REP(i, N){
      int k; cin >> k;
      while(k--){
        int r;
        cin >> r;
        r--;
        sw[i].push_back(r);
      }
      sort(sw[i].begin(), sw[i].end());
    }
    static int d[1 << 16][16] = {};
    static int prev_s[1 << 16][16] = {};
    static int prev_u[1 << 16][16] = {};
    static int act[1 << 16][16] = {};
    static int act_arg[1 << 16][16] = {};
    REP(i, 1 << N) REP(j, N) d[i][j] = INF;
    d[start][0] = 0;
    queue<int> qs, qu;
    qs.push(start);
    qu.push(0);
    while(!qu.empty()){
      int u = qu.front();
      int s = qs.front();
      qu.pop(); qs.pop();
      for(int i = 0; i < sw[u].size(); i++){
        int ns = s ^ (1 << sw[u][i]);
        int v = u;
        if(!(ns >> u & 1)) continue;
        if(d[ns][v] != INF) continue;
        d[ns][v] = d[s][u] + 1;
        qs.push(ns);
        qu.push(v);
        prev_u[ns][v] = u;
        prev_s[ns][v] = s;
        act[ns][v] = ns >> sw[u][i] & 1;
        act_arg[ns][v] = sw[u][i];
      }
      for(int i = 0; i < G[u].size(); i++){
        int v = G[u][i];
        int ns = s;
        if(!(ns >> v & 1)) continue;
        if(d[ns][v] != INF) continue;
        d[ns][v] = d[s][u] + 1;
        qs.push(ns);
        qu.push(v);
        prev_u[ns][v] = u;
        prev_s[ns][v] = s;
        act[ns][v] = 2;
        act_arg[ns][v] = v;
      }
    }
    if(d[1 << (N - 1)][N - 1] != INF){
      printf("You can go home in %d steps.\n",  d[1 << (N - 1)][N - 1]);
      stack<string> actions;
      int cur_s = 1 << (N - 1);
      int cur_u = N - 1;
      while(cur_s != start || cur_u != 0){
        char cs[256];
        if(act[cur_s][cur_u] == 0){
          sprintf(cs, "Switch off room %d.", act_arg[cur_s][cur_u] + 1);
        }else if(act[cur_s][cur_u] == 1){
          sprintf(cs, "Switch on room %d.", act_arg[cur_s][cur_u] + 1);
        }else{
          sprintf(cs, "Move to room %d.", act_arg[cur_s][cur_u] + 1);
        }
        actions.push(string(cs));
        int ns = prev_s[cur_s][cur_u];
        int nu = prev_u[cur_s][cur_u];
        cur_s = ns;
        cur_u = nu;
      }
      while(!actions.empty()){
        cout << actions.top() << endl;
        actions.pop();
      }
    }else {
      bool goal = false;
      REP(s, 1 << N) if(d[s][N - 1] != INF) goal = true;
      if(goal){
        printf("You can not switch off all lights.\n");
      }else{
        printf("Help me!\n");
      }
    }
  }
  return 0;
}

Measured memory_bytes: 21796