#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;

int n, m;
bool u[15][1<<15];
pair<int,int> prev[15][1<<15];
vector<pair<int,int> > action;
vector<int> a[15];
vector<int> b[15];

bool wfs(int p0, int l0, bool f) {
  queue<pair<int, int> > q;
  for (int i=0; i<n; i++) {
    for (int j=0; j<(1<<n); j++) {
      u[i][j] = false;
    }
  }
  q.push(make_pair(p0, l0));
  u[p0][l0] = true;

  while (!q.empty()) {
    int l, p, ll, pp;
    p = q.front().first;
    l = q.front().second;
    q.pop();

    if (!f && p == n-1) return true;
    if (f && p == n-1 && (ll == 1<<n-1)) return true;
    for (int i=0; i<(int)b[p].size(); i++) {
      ll = l ^ (1<<b[p][i]);
      if (!(ll & (1<<p))) continue;
      if (u[p][ll]) continue;
      prev[p][ll].first = p;
      prev[p][ll].second = l;
      u[p][ll] = true;
      q.push(make_pair(p, ll));
    }

    for (int i=0; i<a[p].size(); i++) {
      pp = a[p][i];
      if (!(l & (1<<pp))) continue;
      if (u[pp][l]) continue;
      prev[pp][l].first = p;
      prev[pp][l].second = l;
      u[pp][l] = true;
      q.push(make_pair(pp, l));
    }
  }
  return false;
}

void make_action(int s) {
  int p, l, pp, ll;
  action.clear();
  p = n-1;
  l = (1<<(n-1));
  while (p!=0 || l!=s) {
    pp = prev[p][l].first;
    ll = prev[p][l].second;
    if (p == pp) {
      for (int i=0; i<n; i++) {
        if ((l&(1<<i)) && !(ll&(1<<i))) {
          action.push_back(make_pair(1, i+1));
        } else if (!(l&(1<<i)) && (ll&(1<<i))) {
          action.push_back(make_pair(-1, i+1));
        }
      }
    } else {
      action.push_back(make_pair(0, p+1));
    }
    p = pp;
    l = ll;
  }
  reverse(action.begin(), action.end());
}

int main() {
  int s, t, l;
  while (1) {
    cin >> n >> m;
    if (!n && !m) break;
    l = 0;
    for (int i=0; i<n; i++) {
      a[i].clear();
      b[i].clear();
    }
    for (int i=0; i<m; i++) {
      cin >> s >> t;
      --s;
      --t;
      a[s].push_back(t);
      a[t].push_back(s);
    }
    for (int i=0; i<n; i++) {
      cin >> t;
      if (t) {
        l |= (1<<i);
      }
    }
    for (int i=0; i<n; i++) {
      cin >> s;
      for (int j=0; j<s; j++) {
        cin >> t;
        --t;
        b[i].push_back(t);
      }
    }
    for (int i=0; i<n; i++) {
      sort(b[i].begin(), b[i].end());
    }

    if (wfs(0, l, true)) {
      make_action(l);
      cout << "You can go home in " << action.size() << " steps." << endl;
      for (int i=0; i<(int)action.size(); i++) {
        if (action[i].first == 1) {
          cout << "Switch on room " << action[i].second << "." << endl;
        } else if (action[i].first == -1) {
          cout << "Switch off room " << action[i].second << "." << endl;
        } else {
          cout << "Move to room " << action[i].second << "." << endl;
        }
      }
    } else {
      if (wfs(0, l, false)) {
        cout << "You can not switch off all lights." << endl;
      } else {
        cout << "Help me!" << endl;
      }
    }
  }

  return 0;
}