#include <bits/stdc++.h>
using namespace std;
int sta = 0;
int sw[20];
int n, m;
int dfs(int k, int i) {
  if (i == n + 1) return sta == k ? 1 : 0;
  return dfs(k ^ sw[i], i + 1) + dfs(k, i + 1);
}
int main() {
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    int k;
    cin >> k;
    for (int j = 1; j <= n; j++) sw[j] <<= 1;
    while (k--) {
      int c;
      cin >> c;
      sw[c] += 1;
    }
  }
  int mi[20];
  mi[0] = 1;
  for (int j = 1; j <= m; j++) {
    cin >> mi[j];
  }
  for (int j = m; j >= 1; j--) {
    sta <<= 1;
    sta += mi[j];
  }
  cout << dfs(0, 1);
  return 0;
}
