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

const int N = 15;

enum {OK, OUT, IN};
enum {ID, LIGHT, LOG};
typedef tuple<int, bitset<N>, vector<string>> Node;
typedef tuple<int, unsigned long> Memo;

int n, m;
vector<vector<int>> edge;
vector<vector<int>> button;
vector<string> route;

int bfs(const bitset<N>& init_light) {
    bool out = false;
    int start = 0, goal = n - 1;

    set<Memo> visited;
    queue<Node> q;
    q.push(Node(start, init_light, vector<string>()));
    while(!q.empty()) {
        int id = get<ID>(q.front());
        bitset<N> light = get<LIGHT>(q.front());
        vector<string> log = get<LOG>(q.front());
        q.pop();

        if(visited.count(Memo(id, light.to_ulong()))) continue;
        visited.insert(Memo(id, light.to_ulong()));
// cout << id << ", " << light << ", " << log.size() << endl;

        if(id == goal) {
            out = true;
            bitset<N> check_light = light;
            for(const auto& b: button[id]) check_light.reset(b);
            if(check_light.count() == 1 && check_light[goal]) {
                for(const auto& b: button[id]) if(light[b] != check_light[b]) {
                    char s[20];
                    if(light[b]) sprintf(s, "Switch off room %d.", b + 1);
                    else sprintf(s, "Switch on room %d.", b + 1);
                    log.push_back(string(s));
                }
                route = log;
                return OK;
            }
        }

        for(int bit = 0; bit < 1 << button[id].size(); ++bit) {
            bitset<N> next_light = light;
            for(int i = 0; i < button[id].size(); ++i) {
                if((bit >> i) & 1) next_light.set(button[id][i]);
                else next_light.reset(button[id][i]);
            }
            for(const auto& e: edge[id]) {
                if(!next_light[e]) continue;
                vector<string> next_log = log;
                for(const auto& b: button[id]) {
                    if(light[b] != next_light[b]) {
                        char s[20];
                        if(light[b]) sprintf(s, "Switch off room %d.", b + 1);
                        else sprintf(s, "Switch on room %d.", b + 1);
                        next_log.push_back(string(s));
                    }
                }
                char s[20];
                sprintf(s, "Move to room %d.", e + 1);
                next_log.push_back(string(s));
                q.push(Node(e, next_light, next_log));
// cout << "      " << e << ", " << next_light << ", " << next_log.size() << endl;
            }
        }
    }

    return out ? OUT : IN;
}

int main() {
    while(cin >> n >> m, n | m) {
        edge = vector<vector<int>>(n, vector<int>());
        for(int i = 0; i < m; ++i) {
            int s, t;
            cin >> s >> t; --s; --t;
            edge[s].push_back(t);
            edge[t].push_back(s);
        }
        bitset<N> light(0);
        for(int i = 0; i < n; ++i) {
            int l;
            cin >> l;
            light.set(i, l);
        }
        button = vector<vector<int>>(n, vector<int>());
        for(int i = 0; i < n; ++i) {
            int k;
            for(cin >> k; k > 0; --k) {
                int r;
                cin >> r; --r;
                button[i].push_back(r);
            }
        }

        switch(bfs(light)) {
        case OK:
            cout << "You can go home in " << route.size() << " steps." << endl;
            for(const auto& l: route) cout << l << endl;
            break;
        case OUT:
            cout << "You can not switch off all lights." << endl;
            break;
        case IN:
            cout << "Help me!" << endl;
            break;
        }
    }
}