#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int k;
  int s[m][n];
  for (int i = 0; i < m; i++) {
    cin >> k;
    for (int j = 0; j < k; j++) cin >> s[i][j];
  }
  int p[m];
  for (int i = 0; i < m; i++) cin >> p[i];
  int ans = 0;
  for (int bit = 0; bit < (1 << n); bit++) {
    bool flag = true;
    for (int i = 0; i < m; i++) {
      int cnt = 0;
      for (auto x : s[i]) {
        if (bit & (1 << x - 1)) cnt++;
      }
      if (p[i] != cnt % 2) flag = false;
    }
    if (flag) ans++;
  }
  cout << ans << endl;
}
