#include <bits/stdc++.h>
using namespace std;
int convBin(int n) {
  int t = 1;
  for (int i = 1; i < n; ++i) {
    t *= 2;
  }
  return t;
}
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> switches(n);
  vector<int> lights(m);
  for (int i = 0; i < m; ++i) {
    int cn;
    cin >> cn;
    int key = 0;
    for (int i = 0; i < cn; ++i) {
      int t;
      cin >> t;
      key |= convBin(t);
    }
    switches[i] = key;
  }
  for (int i = 0; i < m; ++i) {
    int t;
    cin >> t;
    lights[i] = t;
  }
  int maxN = 1;
  for (int i = 0; i < n; ++i) {
    maxN *= 2;
  }
  int ans = 0;
  for (int i = 0; i <= maxN; ++i) {
    bool all = true;
    for (int j = 0; j < m; ++j) {
      int key = switches[j];
      int t = i & key;
      int cnt = 0;
      for (int k = t; k > 0; k /= 2) {
        if (k % 2 == 1) {
          ++cnt;
        }
      }
      if (cnt % 2 != lights[j]) {
        all = false;
        break;
      }
    }
    if (all) {
      ++ans;
    }
  }
  cout << ans << endl;
}
