#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        int n, m;
        cin >> n >> m;
        if(n == 0)
            return 0;

        vector<vector<int> > door(n);
        for(int i=0; i<m; ++i){
            int s, t;
            cin >> s >> t;
            -- s;
            -- t;
            door[s].push_back(t);
            door[t].push_back(s);
        }

        bitset<15> light;
        for(int i=0; i<n; ++i){
            int a;
            cin >> a;
            light[i] = (a == 1);
        }

        vector<vector<int> > button(n);
        for(int i=0; i<n; ++i){
            int k;
            cin >> k;
            for(int j=0; j<k; ++j){
                int a;
                cin >> a;
                -- a;
                if(a != i)
                    button[i].push_back(a);
            }
            sort(button[i].begin(), button[i].end());
        }

        queue<pair<int, int> > q;
        q.push(make_pair(0, light.to_ulong()));
        vector<vector<pair<int, int> > > prev(n, vector<pair<int, int> >(1<<n, make_pair(-1, -1)));
        prev[0][light.to_ulong()] = make_pair(0, light.to_ulong());
        bool isCase1 = false;
        bool isCase2 = false;
        while(!q.empty()){
            int curr = q.front().first;
            bitset<15> bs = q.front().second;
            q.pop();
            if(curr == n-1){
                isCase2 = true;
                if(bs == bitset<15>(1<<(n-1))){
                    isCase1 = true;
                    break;
                }
            }
            for(unsigned i=0; i<button[curr].size(); ++i){
                bitset<15> bs2 = bs;
                bs2[button[curr][i]] = !bs2[button[curr][i]];
                if(prev[curr][bs2.to_ulong()].first == -1){
                    q.push(make_pair(curr, bs2.to_ulong()));
                    prev[curr][bs2.to_ulong()] = make_pair(curr, bs.to_ulong());
                }
            }
            for(unsigned i=0; i<door[curr].size(); ++i){
                int next = door[curr][i];
                if(prev[next][bs.to_ulong()].first == -1 && bs[next]){
                    q.push(make_pair(next, bs.to_ulong()));
                    prev[next][bs.to_ulong()] = make_pair(curr, bs.to_ulong());
                }
            }
        }

        if(isCase1){
            vector<string> ret;
            int curr = n-1;
            bitset<15> bs = (1<<(n-1));
            while(curr != 0 || bs != light){
                int i = prev[curr][bs.to_ulong()].first;
                bitset<15> bs2 = prev[curr][bs.to_ulong()].second;
                ostringstream oss;
                if(curr == i){
                    int j = 0;
                    while(bs[j] == bs2[j])
                        ++ j;
                    if(bs[j]){
                        oss << "Switch on room " << (j+1) << '.';
                    }else{
                        oss << "Switch off room " << (j+1) << '.';
                    }
                }else{
                    oss << "Move to room " << (curr+1) << '.';
                }
                ret.push_back(oss.str());
                curr = i;
                bs = bs2;
            }
            cout << "You can go home in " << ret.size() << " steps." << endl;
            for(int i=ret.size()-1; i>=0; --i)
                cout << ret[i] << endl;
        }else if(isCase2){
            cout << "You can not switch off all lights." << endl;
        }else{
            cout << "Help me!" << endl;
        }
    }
}