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