#include<bits/stdc++.h>
using namespace std;

struct data{
    int pos,state,cost;
    data(int pos,int state):pos(pos),state(state){}
};
const int INF=1001001001;

int N,M;
vector<int>G[15];
vector<int>light[15];
int dist[1<<16][15];
int prevstate[1<<16][15],prevpos[1<<16][15];
void solve(int bit){
    fill_n(*dist,(1<<16)*15,INF);
    dist[bit][0]=0;
    queue<data>que;
    que.push(data(0,bit));

    while(que.size()){
        data d=que.front();que.pop();

        for(int i=0;i<light[d.pos].size();i++){
            int l=light[d.pos][i];
            if(l==d.pos)continue;
            int tobit=d.state^(1<<l);
            if(dist[tobit][d.pos]<=dist[d.state][d.pos]+1)continue;
            dist[tobit][d.pos]=dist[d.state][d.pos]+1;
            prevstate[tobit][d.pos]=d.state;
            prevpos[tobit][d.pos]=d.pos;
            que.push(data(d.pos,tobit));
        }

        for(int i=0;i<G[d.pos].size();i++){
            int to=G[d.pos][i];
            if((d.state>>to&1)==0)continue;
            if(dist[d.state][to]<=dist[d.state][d.pos]+1)continue;
            dist[d.state][to]=dist[d.state][d.pos]+1;
            prevstate[d.state][to]=d.state;
            prevpos[d.state][to]=d.pos;
            que.push(data(to,d.state));
        }
    }

    bool flag=false;
    for(int i=0;i<(1<<N);i++)if(dist[i][N-1]!=INF)flag=true;
    if(!flag){
        cout<<"Help me!"<<endl;
        return;
    }

    if(dist[1<<(N-1)][N-1]==INF){
        cout<<"You can not switch off all lights."<<endl;
        return;
    }

    int state=1<<(N-1),pos=N-1;
    cout<<"You can go home in "<<dist[1<<(N-1)][N-1]<<" steps."<<endl;
    vector<string>log;
    while(state!=bit||pos!=0){
        string s;
        if(prevpos[state][pos]!=pos){
            stringstream ss;
            ss<<"Move to room "<<pos+1<<"."<<endl;
            getline(ss,s);
        }
        else{
            for(int i=0;i<N;i++){
                if((prevstate[state][pos]>>i&1)!=(state>>i&1)){
                    stringstream ss;
                    if(state>>i&1)ss<<"Switch on room ";
                    else ss<<"Switch off on room ";
                    ss<<i+1;
                    ss<<"."<<endl;
                    getline(ss,s);
                }
            }
        }

        log.push_back(s);
        int a=prevstate[state][pos];
        int b=prevpos[state][pos];
        state=a;pos=b;
    }

    reverse(log.begin(),log.end());
    for(int i=0;i<log.size();i++)cout<<log[i]<<endl;
}



int main(){
    while(cin>>N>>M,N||M){
        for(int i=0;i<N;i++)G[i].clear();
        for(int i=0;i<N;i++)light[i].clear();

        for(int i=0;i<M;i++){
            int a,b;cin>>a>>b;a--;b--;
            G[a].push_back(b);
            G[b].push_back(a);
        }
        int bit=0;
        for(int i=0;i<N;i++){
            int a;cin>>a;
            if(a)bit|=(1<<i);
        }

        for(int i=0;i<N;i++){
            int k;cin>>k;
            for(int j=0;j<k;j++){
                int a;cin>>a;a--;
                light[i].push_back(a);
            }
        }
        solve(bit);
    }

    return 0;
}