#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 20;
const int MOD = (int)1e9 + 7;
int n, m;
int s[11];
int ss;
void work() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int c;
    cin >> c;
    for (int j = 0; j < c; j++) {
      int x;
      cin >> x;
      s[x] |= 1 << i;
    }
  }
  for (int i = 0; i < m; i++) {
    int x;
    cin >> x;
    ss |= x << i;
  }
  int cnt = 0;
  for (int i = 0; i < (1 << n); i++) {
    int t = 0;
    for (int j = 0; j < n; j++)
      if (i & (1 << j)) t ^= s[j];
    if (t == ss) cnt++;
  }
  cout << cnt << endl;
}
int main() {
  int tc = 1;
  for (int ca = 1; ca <= tc; ca++) {
    work();
  }
  return 0;
}
