#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> B[m];
  int arr[m];
  for (int i = 0; i < m; i++) {
    int k;
    cin >> k;
    for (int j = 0; j < k; j++) {
      int x;
      cin >> x;
      B[i].push_back(x);
    }
  }
  for (int i = 0; i < m; i++) cin >> arr[i];
  int ans = 0;
  for (int mask = 0; mask < (1 << n); mask++) {
    bool pass = true;
    for (int i = 0; i < m; i++) {
      int c = 0;
      for (int& x : B[i]) {
        if ((mask >> x) & 1) c++;
      }
      c %= 2;
      if (c != arr[i]) pass = 0;
    }
    if (pass) ans++;
  }
  cout << ans << '\n';
  return 0;
}
