#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  auto k = vector<int>(m);
  auto s = vector<vector<int>>(m);
  auto p = vector<int>(m);
  for (int i = 0; i < m; i++) {
    cin >> k[i];
    for (int j = 0; j < k[i]; j++) {
      int tmp;
      cin >> tmp;
      s[i].push_back(tmp);
    }
  }
  for (int i = 0; i < m; i++) {
    cin >> p[i];
  }
  int ans = 0;
  int ok;
  for (int i = 0; i < (int)pow(2, n); i++) {
    ok = 1;
    for (int j = 0; j < m; j++) {
      int sum = 0;
      for (int l = 0; l < k[i]; l++) {
        sum = (sum + ((i / (int)pow(2, s[j][l])) % 2)) % 2;
      }
      if (sum != p[j]) {
        ok = 0;
        break;
      }
    }
    if (ok == 1) ans++;
  }
  cout << ans << endl;
  return 0;
}
