#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] + 1); (j)++) cin >> s[i][j];
  }
  for ((i) = (0); (i) < (m); (i)++) cin >> p[i];
  int ans = 0, bit, ok = 1, MAX = 0;
  for ((i) = (0); (i) < (n); (i)++) MAX += pow(2, i);
  for ((bit) = (0); (bit) < (MAX + 1); (bit)++) {
    int swi = 0;
    ok = 1;
    for ((i) = (0); (i) < (m); (i)++) {
      for ((j) = (1); (j) < (s[i][0] + 1); (j)++)
        if (bit & (1 << s[i][j] - 1)) swi++;
      if (swi % 2 == p[i])
        ok *= 1;
      else
        ok *= 0;
    }
    if (ok) ans++;
  }
  cout << ans << endl;
}
