#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æµÜµ½.

//     »ÝÌ®Ô
//     »ÝÇÌ®Ì¾©èªÂ¢Ä¢é©(rbgÇ)
//     Xebv
//     ¡ÜÅÉ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); // dCðÁ·
          else
            tmp.push_back(*its+1); // dCðÂ¯é
          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");
    }
  }
}

Measured memory_bytes: 4028