#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int k[m];
  int s[m][k[m]];
  for (int i = 0; i < m; ++i) {
    cin >> k[i];
    for (int j = 0; j < k[i]; ++j) {
      cin >> s[i][j];
    }
  }
  int p[m];
  for (int i = 0; i < m; ++i) {
    cin >> p[i];
  }
  int ans = 0;
  for (int i = 0; i < (1 << n); ++i) {
    bool a = true;
    for (int j = 0; j < m; ++j) {
      int count = 0;
      for (int l = 0; l < k[j]; ++l) {
        if ((i >> (s[j][l] - 1)) & 1) {
          count += 1;
        }
      }
      if (count % 2 == p[j]) {
      } else {
        a = false;
        break;
      }
    }
    if (a) {
      ans += 1;
    }
  }
  cout << ans << endl;
}
