#include <bits/stdc++.h>
using namespace std;
char to_upper(char x) {
  if (97 <= int(x) && int(x) <= 126)
    return char(x - 32);
  else if (65 <= int(x) && int(x) <= 90)
    return x;
}
char to_lower(char x) {
  if (97 <= int(x) && int(x) <= 126)
    return x;
  else if (65 <= int(x) && int(x) <= 90)
    return char(x + 32);
}
int numerize(char x) {
  if (48 <= int(x) && int(x) <= 57)
    return int(x - '0');
  else if (97 <= int(x) && int(x) <= 126)
    return int(x - 96);
  else if (65 <= int(x) && int(x) <= 90)
    return int(x - 64);
}
int n, m, num[20], p[20];
vector<int> adj[20];
int f;
int deep[20], bulb[20];
void choose(int start, int d, int k) {
  if (d <= k) {
    for (int i = start; i <= n - (k - d); i++) {
      deep[d] = i;
      if (d < k) {
        choose(i + 1, d + 1, k);
      } else {
        for (int j = 1; j <= n; j++) {
          bulb[j] = 0;
        }
        for (int j = 1; j <= k; j++) {
          for (int l = 0; l < adj[deep[j]].size(); l++) {
            int idx = adj[deep[j]][l];
            bulb[idx]++;
          }
        }
        int m2 = 0;
        for (int j = 1; j <= n; j++) {
          if (bulb[j] % 2 == p[j] % 2) {
            m2++;
          }
        }
        if (m2 == n) {
          f++;
        }
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    cin >> num[i];
    for (int j = 1; j <= num[i]; j++) {
      int s;
      cin >> s;
      adj[s].push_back(i);
    }
  }
  for (int i = 1; i <= m; i++) cin >> p[i];
  for (int i = 1; i <= n; i++) {
    choose(1, 1, i);
  }
  cout << f << '\n';
}
