#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>
#include <cassert>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

template <class T, class U>
vector<T> make_v(U size, const T& init){ return vector<T>(static_cast<size_t>(size), init); }

template<class... Ts, class U>
auto make_v(U size, Ts... rest) { return vector<decltype(make_v(rest...))>(static_cast<size_t>(size), make_v(rest...)); }

template<class T> void chmin(T &a, const T &b){ a = (a < b ? a : b); }
template<class T> void chmax(T &a, const T &b){ a = (a > b ? a : b); }

void solve(int n, int m){
    vector<vector<int>> G(n);
    for (int i = 0; i < m; ++i) {
        int a, b;
        scanf("%d %d", &a, &b);
        a--; b--;
        G[a].emplace_back(b);
        G[b].emplace_back(a);
    }
    int st = 0;
    for (int i = 0; i < n; ++i) {
        int x;
        scanf("%d", &x);
        st += x << i;
    }
    vector<vector<int>> sw(n);
    for (int i = 0; i < n; ++i) {
        int k;
        cin >> k;
        for (int j = 0; j < k; ++j) {
            int x;
            cin >> x;
            x--;
            if(x != i) sw[i].emplace_back(x);
        }
    }
    auto dp = make_v(n, 1 << n, INF<int>);
    auto prv = make_v(n, 1 << n, pair<int, int>(0, 0));
    queue<pair<int, int>> Q;
    dp[0][st] = 0;
    Q.emplace(0, st);
    while(!Q.empty()){
        int x, S; tie(x, S) = Q.front(); Q.pop();
        for (auto &&i : G[x]) {
            if((S & (1 << i)) && dp[i][S] > dp[x][S]+1){
                dp[i][S] = dp[x][S]+1;
                prv[i][S] = {x, S};
                Q.emplace(i, S);
            }
        }
        for (auto &&j : sw[x]) {
            if(dp[x][S^(1 << j)] > dp[x][S]+1){
                dp[x][S^(1 << j)] = dp[x][S]+1;
                prv[x][S^(1 << j)] = {x, S};
                Q.emplace(x, S^(1 << j));
            }
        }
    }
    if(dp[n-1][(1 << (n-1))] == INF<int>){
        for (int i = 0; i < 1 << n; ++i) {
            if(dp[n-1][i] != INF<int>){
                puts("You can not switch off all lights.");
                return;
            }
        }
        puts("Help me!");
        return;
    }
    printf("You can go home in %d steps.\n", dp[n-1][1 << (n-1)]);
    vector<pair<int, int>> ans;
    ans.emplace_back(n-1, 1 << (n-1));
    while(ans.back() != pair<int, int>{0, st}){
        ans.emplace_back(prv[ans.back().first][ans.back().second]);
    }
    reverse(ans.begin(),ans.end());
    vector<pair<int, int>> anss;
    
    for (int i = 0; i+1 < ans.size(); ++i) {
        if(ans[i].first != ans[i+1].first){
            anss.emplace_back(0, ans[i+1].first+1);
        }else if(ans[i].second < ans[i+1].second){
            for (int j = 0; j < n; ++j) {
                if((ans[i+1].second^ans[i].second) == (1 << j)){
                    anss.emplace_back(1, j+1);
                    break;
                }
            }
        }else {
            for (int j = 0; j < n; ++j) {
                if((ans[i].second^ans[i+1].second) == (1 << j)){
                    anss.emplace_back(2, j+1);
                    break;
                }
            }
        }
    }
    for (int i = 0; i < anss.size(); ++i) {
        for (int j = 0; j+1 < anss.size(); ++j) {
            if(anss[j].first && anss[j+1].first && anss[j].second > anss[j+1].second){
                swap(anss[j], anss[j+1]);
            }
        }
    }
    for (int i = 0; i < anss.size(); ++i) {
        if(anss[i].first == 0) printf("Move to room %d.\n", anss[i].second);
        if(anss[i].first == 1)  printf("Switch on room %d.\n", anss[i].second);
        if(anss[i].first == 2)  printf("Switch off room %d.\n", anss[i].second);
    }
}

int main() {
    int n, m;
    while(cin >> n >> m, n){
        solve(n, m);
    }
    return 0;
}


Measured memory_bytes: 9220