#include <bits/stdc++.h>
using namespace std;
const int maxn = 500500;
int n, m;
int a[100][100], p[110];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    scanf("%d", &a[i][0]);
    for (int j = 1; j <= a[i][0]; j++) scanf("%d", &a[i][j]);
  }
  for (int i = 1; i <= m; i++) scanf("%d", &p[i]);
  int cnt = 0;
  for (int i = 0; i <= (1 << n) - 1; i++) {
    int flag = 1;
    for (int j = 1; j <= m; j++) {
      int sum = 0;
      for (int k = 1; k <= a[j][0]; k++) {
        if ((i & (1 << (a[j][k] - 1))) != 0) sum++;
      }
      if (sum % 2 != p[i]) flag = 0;
    }
    cnt += flag;
  }
  cout << cnt << endl;
}
