#include <bits/stdc++.h>
using namespace std;
int n, m, ans = 0;
struct lit {
  int num;
  int ask[10];
  int ode;
  int cnt = 0;
};
int fun(int x[]) {
  int i;
  for (i = 1; i <= n; i++)
    if (x[i] != 1) {
      x[i] = 1;
      return 0;
    } else
      x[i] = 0;
  return 0;
}
int main() {
  cin >> n >> m;
  int x[n + 7];
  memset(x, 0, sizeof(x));
  lit b[m + 7];
  for (int i = 1; i <= m; i++) {
    cin >> b[i].num;
    for (int j = 1; j <= b[i].num; j++) {
      cin >> b[i].ask[j];
    }
  }
  for (int i = 1; i <= m; i++) cin >> b[i].ode;
  for (int i = 1; i <= pow(2, n); i++) {
    fun(x);
    for (int j = 1; j <= m; j++) {
      b[j].cnt = 0;
      for (int k = 1; k <= b[j].num; k++) {
        if (x[b[j].ask[k]] == 1) {
          b[j].cnt++;
          continue;
        }
      }
      if (b[j].cnt % 2 == b[j].ode) {
        if (j < m)
          continue;
        else
          ans++;
        break;
      } else
        break;
    }
  }
  cout << ans;
  return 0;
}
