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

using namespace std;

typedef pair<int,int> pii;
vector<int> G[101];
vector<int> operableLights[101];
int d[1<<16][16];
pii prv[1<<16][16];
bool initLight[101];
int N,M;

const int INF=1000000000;

class Sit{
public:
  int room,mask,cost;
  Sit(int r_,int m_,int c_){
    room=r_;mask=m_;cost=c_;
  }
  Sit(){}
};
void dijkstra(){
  for(int i=0;i<(1<<N);i++)
    for(int j=0;j<N;j++)d[i][j]=INF;
  queue<Sit> q;
  int initMask=0;
  for(int i=0;i<N;i++)
    if(initLight[i])initMask|=(1<<i);
  // 最初の部屋に明かりがついているか
  if(initMask%2==1){
    q.push(Sit(0,initMask,0));
    d[initMask][0]=0;
  }
  while(q.size()){
    Sit p=q.front();q.pop();
    int ccost=p.cost;int cmask=p.mask;
    int croom=p.room;int ncost=ccost+1;
    if(d[cmask][croom]<ccost)continue;
    // 部屋移動
    for(int i=0;i<G[croom].size();i++){
      int to=G[croom][i];
      // 移動可能
      if((cmask>>to)&1){
	int nmask=cmask;
	if(d[nmask][to]>ncost){
	  d[nmask][to]=ncost;	  
	  q.push(Sit(to,nmask,ncost));
	  prv[nmask][to]=pii(cmask,croom);
	}
      }
    }
    // ライト操作
    int sz=operableLights[croom].size();
    for(int i=0;i<sz;i++){
      // 部屋のライトは消せない
      if(operableLights[croom][i]==croom)
	continue;
      int nmask=cmask^(1<<operableLights[croom][i]);
      if(d[nmask][croom]>ncost){
    	d[nmask][croom]=ncost;
    	q.push(Sit(croom,nmask,ncost));
	prv[nmask][croom]=pii(cmask,croom);
      }
    }
  }
  // 脱出でき、さいごの部屋以外の電気を消せる
  if(d[1<<(N-1)][N-1]!=INF){
    cout<<"You can go home in ";
    cout<<d[1<<(N-1)][N-1];
    cout<<" steps."<<endl;
    pii cur=pii(1<<(N-1),N-1);
    vector<pii> vp;
    while(!(cur.first==initMask&&cur.second==0)){
      pii pv=prv[cur.first][cur.second];
      int cmask=cur.first;
      int pmask=pv.first;
      if(cmask!=pmask){
	int diff=cmask^pmask;
	for(int i=0;i<N;i++){
	  if((diff>>i)&1){
	    // on
	    if(cmask>pmask)vp.push_back(pii(0,i));
	    // off
	    else vp.push_back(pii(1,i));
	    break;
	  }
	}
      }
      // move to nxt room
      else vp.push_back(pii(2,cur.second));
      cur=pv;
    }
    for(int i=vp.size()-1;i>=0;i--){
      vp[i].second++;
      if(vp[i].first==0){
	cout<<"Switch on room ";
	cout<<vp[i].second<<"."<<endl;
      }
      else if(vp[i].first==1){
	cout<<"Switch off room ";
	cout<<vp[i].second<<"."<<endl;
      }
      else{
	cout<<"Move to room ";
	cout<<vp[i].second<<"."<<endl;
      }
    }
  }
  else{
    bool ok=false;
    // ゴールにたどり着くことが可能
    for(int i=0;i<(1<<N);i++)
      if(d[i][N-1]!=INF)ok=true;
    if(ok){
      cout<<"You can not switch off all lights.";
      cout<<endl;
    }
    else cout<<"Help me!"<<endl;
  }
}

int main(){

  while(cin>>N>>M&&(N|M)){
    for(int i=0;i<101;i++)G[i].clear();
    for(int i=0;i<M;i++){
      int s,t;
      cin>>s>>t;
      s--;t--;
      G[s].push_back(t);
      G[t].push_back(s);
    }
    for(int i=0;i<N;i++){
      int a;
      cin>>a;
      initLight[i]=a;
    }
    for(int i=0;i<N;i++){
      int k;
      cin>>k;
      operableLights[i].clear();
      for(int j=0;j<k;j++){
	int a;
	cin>>a;
	a--;
	operableLights[i].push_back(a);
      }
      sort(operableLights[i].begin(),
	   operableLights[i].end());
    }
    dijkstra();
  }
  return 0;
}

Measured memory_bytes: 0