#include <algorithm>
#include <cstdio>
#include <queue>
#include <vector>

static const size_t n_max = 15;
static size_t ps[1 << n_max][n_max];

static size_t encode(size_t s, size_t ls) {
  return s << n_max | ls;
}

static void decode(size_t x, size_t &s, size_t &ls) {
  s = x >> n_max;
  ls = x & ((1 << n_max) - 1);
}

int main() {
  for (;;) {
    size_t n, m;
    scanf("%zu%zu", &n, &m);
    if (!n && !m)
      return 0;
    for (size_t x = 0; x < (1u << n); x++)
      for (size_t s = 0; s < n; s++)
        ps[x][s] = size_t(-1);
    std::vector<size_t> es[n_max], rs[n_max];
    for (size_t i = 0; i < m; i++) {
      size_t s, t;
      scanf("%zu%zu", &s, &t);
      es[s-1].push_back(t-1);
      es[t-1].push_back(s-1);
    }
    size_t ls = 0;
    for (size_t i = 0; i < n; i++) {
      size_t l;
      scanf("%zu", &l);
      ls |= l << i;
    }
    for (size_t i = 0; i < n; i++) {
      size_t k;
      scanf("%zu", &k);
      for (size_t j = 0; j < k; j++) {
        size_t r;
        scanf("%zu", &r);
        rs[i].push_back(r - 1);
      }
    }
    const size_t start = encode(0, ls), goal = encode(n-1, 1 << (n-1));
    std::queue<size_t> q;
    q.push(start);
    ps[ls][0] = size_t(-2);
    int c = 3;
    while (q.size()) {
      size_t x = q.front(), s, ls;
      decode(x, s, ls);
      if (x == goal) {
        c = 1;
        break;
      }
      if (s == n - 1)
        c = 2;
      q.pop();
      for (auto t : es[s])
        if ((ls & (1 << t)) && ps[ls][t] == size_t(-1)) {
          ps[ls][t] = x;
          q.push(encode(t, ls));
        }
      for (auto t : rs[s]) {
        auto ks = ls ^ (1 << t);
        if (ps[ks][s] == size_t(-1)) {
          ps[ks][s] = x;
          q.push(encode(s, ks));
        }
      }
    }
    switch (c) {
      case 1:
        {
          std::vector<std::pair<int, size_t>> steps;
          for (size_t x = goal; x != start;) {
            size_t s, ls;
            decode(x, s, ls);
            size_t y = ps[ls][s], t, ks;
            decode(y, t, ks);
            if (s != t)
              steps.push_back(std::make_pair(0, s));
            else
              for (size_t i = 1; i < (1u << n); i <<= 1)
                if ((ls & i) != (ks & i)) {
                  steps.push_back(std::make_pair((ls & i) ? 1 : -1, i));
                  break;
                }
            x = y;
          }
          std::reverse(steps.begin(), steps.end());
          printf("You can go home in %zu steps.\n", steps.size());
          for (auto &&p : steps)
            if (!p.first)
              printf("Move to room %zu.\n", p.second + 1);
            else if (p.first > 0)
              printf("Switch on room %zu.\n", p.second + 1);
            else
              printf("Switch off room %zu.\n", p.second + 1);
        }
        break;
      case 2:
        puts("You can not switch off all lights.");
        break;
      case 3:
        puts("Help me!");
        break;
    }
  }
}