#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <queue>
#include <map>
#include <set>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <bitset>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

// ÌSÏðóÔÆµÄà½¹Ä, DæµÜµ½.

//     »ÝÌ®Ô
//     »ÝÇÌ®Ì¾©èªÂ¢Ä¢é©(rbgÇ)
//     Xebv
//     ¡ÜÅÉsÁ½®ì(vector<int>Ç)

// ®ìÍRíÞ èÜ·ª, e®ìðÌæ¤Éint^ÐÆÂÅ¯ÊÅ«éæ¤ÉµÜµ½.

//     1Èã, 100¢Ì³® : ±ÌÔÌ¾©èðÂ¯½
//     0¢Ì® : (±ÌÔ * (-1)) Ì¾©èðÁµ½
//     101ÈãÌ³® : (±ÌÔ - 100) Ì®ÉÚ®µ½

struct P {
  int n;
  int S;
  int step;
  vector<int> op;
  P(int n,int S, int step, vector<int> op) :
    n(n), S(S), step(step), op(op) {}
};

bool visited[15][1<<15];
  
int main() {
  int n,m ;
  while(cin >> n>>m, n||m) {
    vector<int> door[n];
    REP(i,m) {
      int s,t;
      cin >> s>>t;
      door[s-1].push_back(t-1);
      door[t-1].push_back(s-1);
    }
    int shokiS = 0;
    REP(i,n) {
      int a;
      cin >> a;
      if (a) shokiS |= 1<<i;
    }
    vector<int> swch[n];
    REP(i,n) {
      int k;
      cin >> k;
      REP(j,k) {
        int r;
        cin >> r;
        swch[i].push_back(r-1);
      }
      sort(ALL(swch[i]));
    }

    queue<P> Q;
    Q.push(P(0, shokiS, 0, vector<int>()));
    bool f = 0;
    vector<int> resop;
    memset(visited,0,sizeof(visited));
    while(!Q.empty()) {
      P now = Q.front(); Q.pop();

      if (visited[now.n][now.S]) continue;
      visited[now.n][now.S] = 1;
      
//       cout << now.n << " " << bitset<4>(now.S) << " " << now.step <<endl;
       if (now.n == n-1 && now.S == (1<<(n-1))) {
        resop = now.op;
        break;
      }
      if (now.n == n-1)
        f = 1;
      
      FOR(its, swch[now.n]) {
        if (*its!=now.n && !visited[now.n][now.S^(1<<*its)]) {
          //        cout << *its << " " << (now.S^(1<<(*its))) << endl;
          vector<int> tmp = now.op;
          if (now.S>>*its&1)
            tmp.push_back(-*its-1); // dCðÁ·
          else
            tmp.push_back(*its+1); // dCðÂ¯é
          Q.push(P(now.n, now.S^(1<<*its), now.step+1, tmp));     
        }
      }
      FOR(itd, door[now.n]) {
        //cout << *itd << ": " << endl;
        if ((now.S>>(*itd)&1) && !visited[*itd][now.S]) {
          //cout << "hogeta" << endl;
          vector<int> tmp = now.op;
          tmp.push_back(101+*itd);
          Q.push(P(*itd, now.S, now.step+1, tmp));
        }
      }
    }
    if (resop.size()) {
      printf("You can go home in %d steps.\n", resop.size());
      FOR(it, resop) {
        if (0<*it && *it<=100) {
          printf("Switch on room %d.\n", *it);
        } else if (*it<0) {
          printf("Switch off room %d.\n", -*it);
        } else {
          printf("Move to room %d.\n", *it-100);
        }
      }
    } else if (f) {
      printf("You can not switch off all lights.\n");
    } else  {
      printf("Help me!\n");
    }
  }
}