#include<iostream>
#include<queue>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define MAX 15
#define rep(i,n) for(int i=0;i<int(n);i++)
int nn,m;
vector<int> g[MAX],r[MAX];
bool used[1<<MAX][MAX];
struct Q{
  bool is_move;
  bool is_on;
  int s;
  bool operator<(const Q& q)const{return s<q.s;}
  Q(){}
  Q(bool i,bool o,int s_):is_move(i),is_on(o),s(s_){}
};
struct P{
  int u,n;
  vector<Q> v;
  P(int u_,int n_,const vector<Q>& v_):u(u_),n(n_),v(v_){}
};
void solve(int u)
{
  memset(used,0,sizeof(used));
  queue<P> q;
  vector<Q> v;
  q.push( P(u,0,vector<Q>()) );
  used[u][0]=true;
  bool can=false,all=false;
  if( !(u&1) )goto END;
  while( !q.empty() ){
    P p=q.front(); q.pop();
    int n=p.n;
    u=p.u;
    if( n==nn-1 ){
      can=true;
      if( u==(1<<(nn-1)) ){
        all=true;
        v=p.v;
        goto END;
      }
    }
    //move
    rep(i,g[n].size()){
      //printf("%d -> %d %d\n",n,g[n][i],i);
      if( u&(1<<g[n][i]) && !used[u][g[n][i]] ){
        used[u][g[n][i]]=true;
        v=p.v;
        v.push_back( Q(true,false,g[n][i]) );
        q.push( P(u,g[n][i],v) );
      }
    }
    //switch
    rep(i,r[n].size()){
      bool is_on=!(u&(1<<r[n][i]));
      int uu=u^(1<<r[n][i]);
      if( !used[uu][n] ){
        used[uu][n]=true;
        v=p.v;
        v.push_back( Q(false,is_on,r[n][i]) );
        q.push( P(uu,n,v) );
      }
    }
  }
END:;
  if( !can ){
    puts("Help me!");
  } else if( !all ){
    puts("You can not switch off all lights.");
  } else {
    printf("You can go home in %d steps.\n",v.size());
    for(vector<Q>::iterator it=v.begin();it!=v.end();++it){
      if(!it->is_move){
        vector<Q>::iterator iit;
        for(iit=it;iit+1!=v.end() && !iit->is_move;++iit);
        sort(it,iit);
        it=iit;
      }
    }
    rep(i,v.size()){
      Q& q=v[i];
      if(q.is_move){
        printf("Move to room %d.\n",q.s+1);
      } else {
        printf("Switch %s room %d.\n",q.is_on?"on":"off",q.s+1);
      }
    }
  }
}
int main(void)
{
  for(;;){
    scanf("%d%d",&nn,&m); if(!nn)break;
    int s,t;
    rep(i,m){
      scanf("%d%d",&s,&t);
      s--; t--;
      g[s].push_back(t);
      g[t].push_back(s);
    }
    int a,u=0;
    rep(i,nn){
      scanf("%d",&a);
      u|=a<<i;
    }
    int k,l;
    rep(i,nn){
      scanf("%d",&k);
      rep(j,k){
        scanf("%d",&l); l--;
        if(l==i)continue;
        r[i].push_back(l);
      }
      sort(r[i].begin(),r[i].end());
      sort(g[i].begin(),g[i].end());
    }
    solve(u);
    rep(i,nn)g[i].clear();
    rep(i,nn)r[i].clear();
  }
}