#include<iostream>
#include<queue>
#include<set>
#include<vector>
#include<tuple>
using namespace std;

const int N = 15;

enum {OK, OUT, IN};
enum {ACTION, ROOM, MOVE, OFF, ON};
typedef tuple<int, int> Action;
enum {ID, LIGHT, LOG};
typedef tuple<int, int, vector<Action>> Node;
typedef tuple<int, int> Memo;

int n, m;
vector<vector<int>> door;
vector<vector<int>> button;
vector<Action> route;

int bfs(int initial_light) {
    bool out = false;
    set<Memo> visited;
    queue<Node> q;
    q.push(Node(0, initial_light, vector<Action>()));

    while(!q.empty()) {
        int id = get<ID>(q.front());
        int light = get<LIGHT>(q.front());
        vector<Action> log = get<LOG>(q.front());
        q.pop();

        if(visited.count(Memo(id, light))) continue;
        visited.insert(Memo(id, light));
        if(id == n - 1) {
            int check_light = light;
            for(const auto& b: button[id]) if(check_light & (1 << b)) check_light ^= 1 << b;
            if(check_light == (1 << n - 1)) {
                for(const auto& b: button[id]) {
                    if((light & (1 << b)) != (check_light & (1 << b))) {
                        if(light & (1 << b)) log.push_back(Action(OFF, b));
                        else log.push_back(Action(ON, b));
                    }
                }
                route = log;
                return OK;
            }
            out = true;
        }

        for(int bit = 0; bit < 1 << button[id].size(); ++bit) {
            int next_light = light;
            for(int i = 0; i < button[id].size(); ++ i) {
                if(bit & (1 << i)) next_light |= 1 << button[id][i];
                else if(next_light & (1 << button[id][i])) next_light ^= 1 << button[id][i];
            }
            vector<Action> next_log = log;
            for(const auto& b: button[id]) {
                if((light & (1 << b)) != (next_light & (1 << b))) {
                    if(light & (1 << b)) next_log.push_back(Action(OFF, b));
                    else next_log.push_back(Action(ON, b));
                }
            }
            for(const auto& d: door[id]) {
                if((next_light & (1 << d)) == 0) continue;
                next_log.push_back(Action(MOVE, d));
                q.push(Node(d, next_light, next_log));
                next_log.pop_back();
            }
        }
    }
    return out ? OUT : IN;
}

int main() {
    while(cin >> n >> m, n | m) {
        int s, t, l, k, r;
        int light = 0;
        door = vector<vector<int>>(n, vector<int>());
        button = vector<vector<int>>(n, vector<int>());
        for(int i = 0; i < m; ++i) {
            cin >> s >> t; --s; --t;
            door[s].push_back(t);
            door[t].push_back(s);
        }
        for(int i = 0; i < n; ++i) {
            cin >> l;
            if(l) light |= 1 << i;
        }
        for(int i = 0; i < n; ++i) {
            for(cin >> k; k > 0; --k) {
                cin >> r; --r;
                button[i].push_back(r);
            }
        }
        int result = bfs(light);
        if(result == OK) {
            cout << "You can go home in " << route.size() << " steps." << endl;
            for(const auto& r: route) {
                int action = get<ACTION>(r);
                int room = get<ROOM>(r);
                ++room;
                if(action == MOVE) cout << "Move to room " << room << "." << endl;
                else if(action == OFF) cout << "Switch off room " << room << "." << endl;
                else cout << "Switch on room " << room << "." << endl;
            }
        } else if(result == OUT) {
            cout << "You can not switch off all lights." << endl;
        } else {
            cout << "Help me!" << endl;
        }
    }
}