#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <complex>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <iterator>

using namespace std;

#define dump(n) cout<<"# "<<#n<<'='<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define iter(c) __typeof__((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();++i)
#define all(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int,int> pii;

const int INFTY=1<<29;
const double EPS=1e-9;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
	os<<'[';
	rep(i,a.size()) os<<(i?" ":"")<<a[i];
	return os<<']';
}

int main()
{
	for(int n,m;cin>>n>>m,n|m;){
		vvi g(n);
		rep(i,m){
			int s,t; cin>>s>>t; s--,t--;
			g[s].push_back(t);
			g[t].push_back(s);
		}
		int initial=0;
		rep(i,n){
			int x; cin>>x;
			initial|=x<<i;
		}
		vvi ss(n);
		rep(i,n){
			int k; cin>>k;
			rep(j,k){
				int x; cin>>x;
				ss[i].push_back(x-1);
			}
			sort(all(ss[i]));
		}
		
		if(!(initial&1)){
			puts("Help me!");
			continue;
		}
		
		vector<vector<pii>> prev(n,vector<pii>(1<<n,mp(-1,-1)));
		prev[0][initial]=mp(-2,-2);
		queue<pii> q; q.emplace(0,initial);
		while(!q.empty()){
			pii cur=q.front(); q.pop();
			int ci=cur.first,cs=cur.second;
			rep(i,ss[ci].size()) if(ss[ci][i]!=ci){
				int ns=cs^1<<ss[ci][i];
				if(prev[ci][ns]==mp(-1,-1)){
					prev[ci][ns]=mp(ci,cs);
					q.emplace(ci,ns);
				}
			}
			for(int ni:g[ci]){
				if((cs&1<<ni) && prev[ni][cs]==mp(-1,-1)){
					prev[ni][cs]=mp(ci,cs);
					q.emplace(ni,cs);
				}
			}
		}
		
		if(prev[n-1][1<<n-1]!=mp(-1,-1)){
			deque<pii> res;
			for(pii x=mp(n-1,1<<n-1);x!=mp(-2,-2);x=prev[x.first][x.second])
				res.push_front(x);
			printf("You can go home in %d steps.\n",res.size()-1);
			repi(i,1,res.size()){
				if(res[i-1].first!=res[i].first)
					printf("Move to room %d.\n",res[i].first+1);
				else{
					int x=__builtin_ctz(res[i-1].second^res[i].second);
					if(res[i].second&1<<x)
						printf("Switch on room %d.\n",x+1);
					else
						printf("Switch off room %d.\n",x+1);
				}
			}
		}
		else if(count(all(prev[n-1]),mp(-1,-1))<(1<<n))
			puts("You can not switch off all lights.");
		else
			puts("Help me!");
	}
	
	return 0;
}