#include <bits/stdc++.h>
const int INT_INF = 1e9;
const long long LONG_INF = 1e18;
const long long MOD = 1e9 + 7;
const double PI = 3.14159265358979323846;
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> s(m, vector<int>(n, 0));
  vector<int> p(m);
  for (int i = 0; i < m; i++) {
    int k;
    cin >> k;
    for (int j = 0; j < k; j++) {
      cin >> s[i][j];
    }
  }
  for (int i = 0; i < m; i++) {
    cin >> p[i];
  }
  int ans = 0;
  bool f = true;
  for (int i = 0; i < 1 << n; i++) {
    f = true;
    for (int j = 0; j < m; j++) {
      int k = 0;
      int count = 0;
      while (s[j][k] != 0) {
        if ((1 & i >> (s[j][k] - 1)) == 1) {
          count++;
        }
        k++;
      }
      if (count % 2 != p[j]) {
        f = false;
        break;
      }
    }
    if (f) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
