#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  vector<vector<int>> light(M);
  for (int i = 0; i < (M); i++) {
    int K;
    cin >> K;
    for (int k = 0; k < (K); k++) {
      int s;
      cin >> s;
      s--;
      light[i].push_back(s);
    }
  }
  vector<int> p(M);
  for (int i = 0; i < (M); i++) {
    cin >> p[i];
  }
  int ans = 0;
  for (int i = 0; i < (pow(2, N)); i++) {
    bool flag = true;
    for (int m = 0; m < (M); m++) {
      bool isOn = p[m];
      for (auto e : light[m]) {
        isOn = (i & (1 << e)) ? !isOn : isOn;
      }
      if (!isOn) {
        flag = false;
      }
    }
    if (flag) ans++;
  }
  cout << ans << endl;
}
