#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define ALL(A)		(A).begin(),(A).end()
#define DUMP(A)    cout<<#A<<"="<<(A)<< endl
#define SIZE(A)    (int)((A).size())
using namespace std;
typedef long long ll;

int dp[1<<15][15];
bool ispa[15][15],isswi[15][15],isend[1<<15][15];
pair<int,int> dpbef[1<<15][15];
const int INF=1000000;
int n;

int solve(int li,int pos){
    if(isend[li][pos]) return dp[li][pos];
    if((li&(1<<pos))==0) return INF;
    isend[li][pos]=true;
    int ans=INF,befli,befpos;
    for(int i=0;i<n;i++){
        if(ispa[i][pos]){
            int res=solve(li,i)+1;
            if(res<ans){
                ans=res;
                befli=li;
                befpos=i;
            }
        }
    }
    for(int i=n-1;i>=0;i--){
        if(isswi[pos][i]){
            int nowli;
            if(li&(1<<i)) nowli=li-(1<<i);
            else nowli=li+(1<<i);
            int res=solve(nowli,pos)+1;
            if(res<ans){
                ans=res;
                befli=nowli;
                befpos=pos;
            }
        }
    }
    dp[li][pos]=ans;
    dpbef[li][pos]=make_pair(befli,befpos);
    return dp[li][pos];
}

int main(){
    for(;;){
        int m;
        scanf("%d%d",&n,&m);
        if(n==0&&m==0) break;
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                ispa[i][j]=false;
            }
        }
        for(int i=0;i<m;i++){
            int s,t;
            scanf("%d%d",&s,&t);
            s--;t--;
            ispa[s][t]=ispa[t][s]=true;
        }
        int fstli=0;
        for(int i=0;i<n;i++){
            int li;
            scanf("%d",&li);
            fstli|=li<<i;
        }
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                isswi[i][j]=false;
            }
        }
        for(int i=0;i<n;i++){
            int k;
            scanf("%d",&k);
            for(int j=0;j<k;j++){
                int r;
                scanf("%d",&r);
                r--;
                isswi[i][r]=true;
            }
        }
        for(int i=0;i<(1<<n);i++){
            for(int j=0;j<n;j++){
                dp[i][j]=INF;
                isend[i][j]=false;
            }
        }
        isend[fstli][0]=true;
        dp[fstli][0]=0;
        dpbef[fstli][0]=make_pair(fstli,0);
        if(solve(1<<(n-1),n-1)<INF||solve(0,n-1)<INF){
            int nowli,nowpos=n-1;
            if(solve(1<<(n-1),n-1)<INF){
                nowli=1<<(n-1);
            }else nowli=0;
            vector<string> outs;
            for(int i=0;;i++){
                pair<int,int> res=dpbef[nowli][nowpos];
                int befli=res.first,befpos=res.second;
                if(nowli==befli&&nowpos==befpos) break;
                stringstream ss;
                if(nowpos!=befpos){
                    ss<<"Move to room "<<nowpos+1<<".";
                }
                if(befli<nowli){
                    for(int i=0;i<n;i++){
                        if(befli+(1<<i)==nowli){
                            ss<<"Switch on room "<<i+1<<".";
                            break;
                        }
                    }
                }else if(befli>nowli){
                    for(int i=0;i<n;i++){
                        if(befli==nowli+(1<<i)){
                            ss<<"Switch off room "<<i+1<<".";
                            break;
                        }
                    }
                }
                outs.push_back(ss.str());
                nowli=befli;
                nowpos=befpos;
            }
            cout<<"You can go home in "<<outs.size()<<" steps."<<endl;
            for(int i=outs.size()-1;i>=0;i--){
                cout<<outs[i]<<endl;
            }
        }else{
            bool isany=false;
            for(int i=0;i<(1<<n);i++){
                if(solve(i,n-1)<INF){
                    isany=true;
                }
            }
            if(isany) printf("You can not switch off all lights.\n");
            else printf("Help me!\n");
        }
    }
}