#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <sstream>
using namespace std;

enum
{
	MOVE,
	PUSH,
};

struct Action
{
	Action() : act( 0 ), num( 0 ){}
	Action( int a, int n ) : act( a ), num( n ){}
	int act;
	int num;
};

struct Room
{
	Room() : buttonSet( 0 ){}
	vector< int > door;
	vector< int > button;
	int buttonSet;
};

string intToStr( int d )
{
	string ret;
	stringstream ss;
	ss << d;
	ss >> ret;
	return ret;
}

bool isLightOn( int light, int n )
{
	if( light == ( 1 << n ) ){
		return false;
	}
	return true;
}

int rec( int n, int pos, vector< Room >& room, int light, vector< set< int > >& state, vector< Action >& act, bool& arrived )
{
	//以前訪れた時と電気の状況が同じだとループしていることに
	set< int >::iterator itr = state[ pos ].begin();
	while( itr != state[ pos ].end() ){
		if( light == *itr ){
			return light;
		}
		++itr;
	}
	//部屋が真っ暗
	if( !( light & ( 1 << pos ) ) ){
		return light;
	}
	//ゴール部屋
	if( pos == n ){
		arrived = true;
	}


	int numDoors = room[ pos ].door.size();
	for( int i = 0; i < numDoors; ++i ){
		int push = 1 << n;
		int buttons = room[ pos ].buttonSet;
		set< int > tested;
		for( int j = 0; j < push; ++j ){
			int pat = ( j << 1 ) & buttons;
			if( tested.find( pat ) != tested.end() ){
				continue;
			}
			tested.insert( pat );
			int nextState = light ^ pat;
			if( state[ pos ].find( nextState ) != state[ pos ].end() ){
				continue;
			}
			state[ pos ].insert( nextState );
			if( pat ) {
				act.push_back( Action( PUSH, pat ) );
			}
			if( pos == n && !( isLightOn( nextState, n ) ) ){
				return 0;
			}
			act.push_back( Action( MOVE, room[ pos ].door[ i ] ) );
			state[ pos ].insert( nextState );
			if( rec( n, room[ pos ].door[ i ], room, nextState, state, act, arrived ) == 0 ){
				return 0;
			}
			if( pat ){
				act.pop_back();
			}
			act.pop_back();
			state[ pos ].erase( nextState );
		}
	}

	return light;
}

vector< string > solve( int n, vector< Room >& room, int light )
{
	bool arrived = false;
	vector< string > ans;
	vector< Action > act;
	vector< set< int > > state( n + 1, set< int >() );
	int res = rec( n, 1, room, light, state, act, arrived );
	if( arrived ){
		if( res > 0 ){
			ans.push_back( "You can not switch off all lights." );
		}else{
			for( int i = 0; i < (int)act.size(); ++i ){
				switch( act[ i ].act ){
					case MOVE:
						ans.push_back( "Move to room " + intToStr( act[ i ].num ) + "." );
						break;
					case PUSH:
						{
							int pat = act[ i ].num;
							light ^= pat;
							int cnt = 1;
							while( cnt <= n ){
								int push = 1 << cnt;
								if( pat & push ){
									if( light & push ){
										ans.push_back( "Switch on room " + intToStr( cnt ) + "." );
									}else{
										ans.push_back( "Switch off room " + intToStr( cnt ) + "." );
									}
								}
								++cnt;
							}
						}
						break;
				}
			}
			ans.insert( ans.begin(), "You can go home in " + intToStr( ans.size() ) + " steps." );
		}
	}else{
		ans.push_back( "Help me!" );
	}
	return ans;
}

void input( int n, int m, vector< Room >& room, int& light )
{
	room.resize( n + 1 );
	for( int i = 0; i < m; ++i ){
		int a, b;
		cin >> a >> b;
		room[ a ].door.push_back( b );
		room[ b ].door.push_back( a );
	}
	for( int i = 1; i <= n; ++i ){
		int l;
		cin >> l;
		light |= ( l << i );
	}
	for( int i = 1; i <= n; ++i ){
		int k;
		cin >> k;
		room[ i ].button.resize( k );
		for( int j = 0; j < k; ++j ){
			int b;
			cin >> b;
			room[ i ].button[ j ] = b;
			room[ i ].buttonSet |= ( 1 << b );
		}
	}
}

int main()
{
	int n, m;

	while( cin >> n >> m && ( n || m ) ){
		vector< Room > room;
		int light = 0;
		input( n, m, room, light );

		vector< string > ans = solve( n, room, light );

		for( int i = 0; i < (int)ans.size(); ++i ){
			cout << ans[ i ] << endl;
		}
	}

	return 0;
}