#include <bits/stdc++.h>
using namespace std;
class game {
 public:
  int N, M;
  vector<vector<int> > Ss;
  vector<int> Ps;
  int ans = 0;
  void Input() {
    cin >> N >> M;
    int k;
    int s;
    for (int mi = 0; mi < M; mi++) {
      cin >> k;
      vector<int> ls;
      for (int ki = 0; ki < k; ki++) {
        cin >> s;
        ls.push_back(s - 1);
      }
      Ss.push_back(ls);
    }
    int p;
    for (int ni = 0; ni < M; ni++) {
      cin >> p;
      Ps.push_back(p);
    }
  }
  int TryS(int ni, vector<int> ls) {
    if (ni == N) {
      int si;
      int sum;
      int flag = 1;
      for (int mi = 0; mi < M; mi++) {
        sum = 0;
        for (int ssi = 0; ssi < Ss[mi].size(); ssi++) {
          si = Ss[mi][ssi];
          sum += ls[ssi];
        }
        if (sum % 2 != Ps[mi]) {
          flag = 0;
          break;
        }
      }
      if (flag) {
        ans++;
      }
      return 0;
    }
    vector<int> new_ls = ls;
    new_ls[ni] = 0;
    TryS(ni + 1, new_ls);
    new_ls[ni] = 1;
    TryS(ni + 1, new_ls);
    return 1;
  }
};
int main() {
  game g;
  g.Input();
  g.TryS(0, vector<int>(g.N, 0));
  printf("%d", g.ans);
  return 0;
}
