#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n, m;
  int *k, **s, *p;
  int pattern = 1;
  int count = 0;
  k = new int[m];
  s = new int *[m];
  p = new int[m];
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> k[i];
    s[i] = new int(k[i]);
    for (int j = 0; j < k[i]; j++) {
      cin >> s[i][j];
      s[i][j] -= 1;
    }
  }
  for (int i = 0; i < n; i++) pattern *= 2;
  for (int i = 0; i < m; i++) {
    cin >> p[i];
  }
  count = pattern;
  for (int bits = 0; bits < pattern; bits++) {
    for (int i = 0; i < m; i++) {
      int l = 0;
      for (int j = 0; j < k[i]; j++) {
        l += ((bits & (1 << s[i][j])) != 0);
      }
      if (l % 2 != p[i]) {
        count--;
        break;
      }
    }
  }
  cout << count << endl;
  return 0;
}
