#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int s[m][n];
  for (int i = 1; i <= m; i++) {
    cin >> s[i][0];
    for (int j = 1; j <= s[i][0]; j++) cin >> s[i][j], s[i][j]--;
  }
  int p[m];
  for (int i = 1; i <= m; i++) cin >> p[i];
  int ans = 0;
  for (int bit = 0; bit <= pow(2, n) - 1; bit++) {
    int sum = 0;
    for (int j = 1; j <= m; j++) {
      int tot = 0;
      for (int k = 1; k <= s[j][0]; k++) {
        if (bit & 1 << s[j][k]) tot++;
      }
      if (tot % 2 == p[j]) sum++;
    }
    if (sum == m) ans++;
  }
  cout << ans << endl;
  return 0;
}
