#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> s_arr(m);
  for (int i = 0; i < m; ++i) {
    int k;
    cin >> k;
    s_arr[i] = 0;
    for (int j = 0; j < k; ++j) {
      int num;
      cin >> num;
      s_arr[i] |= (1 << (num - 1));
    }
  }
  vector<int> p_arr(m);
  for (int i = 0; i < m; ++i) {
    cin >> p_arr[i];
  }
  int ans = 0;
  for (int i = 0; i < (1 << n); ++i) {
    for (int j = 0; j < m; ++j) {
      int sum = 0;
      for (int k = 0; k < (1 << n); ++k) {
        if (s_arr[j] & ((1 << k) & i)) {
          sum++;
        }
      }
      if (sum % 2 == p_arr[j]) {
        if (j == m - 1) {
          ans++;
        }
      } else {
        break;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
