#include <bits/stdc++.h>
using namespace std;
vector<int> binaryConvert(int x, int digit) {
  vector<int> binary(1);
  while (x > 0) {
    binary.insert(binary.begin(), x % 2);
    x = x / 2;
  }
  binary.pop_back();
  while (binary.size() < digit) {
    binary.insert(binary.begin(), 0);
  }
  return binary;
}
int main() {
  int n, m;
  cin >> n >> m;
  int *k = new int[m];
  int s[10][10] = {-1};
  int *p = new int[m];
  for (int i = 0; i < m; i++) {
    cin >> k[i];
    for (int j = 0; j < k[i]; j++) {
      cin >> s[i][j];
    }
  }
  for (int i = 0; i < m; i++) {
    cin >> p[i];
  }
  int ans = 0;
  bool flag = true;
  int swichOnSum = 0;
  for (int i = 1; i < 1 << n; i++) {
    flag = true;
    vector<int> swichStatus = binaryConvert(i, n);
    for (int j = 0; j < m && flag; j++) {
      for (int h = 0; h < k[j]; h++) {
        swichOnSum += swichStatus[s[j][h] - 1];
      }
      if (swichOnSum % 2 != p[j]) {
        flag = false;
        break;
      }
      swichOnSum = 0;
    }
    if (flag) {
      ans += 1;
    }
  }
  cout << ans << endl;
}
