#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> light(m);
  for (int i = 0; i < m; ++i) {
    int k;
    cin >> k;
    for (int j = 0; j < k; ++j) {
      light[i].resize(k);
      cin >> light[i][j];
      --light[i][j];
    }
  }
  vector<int> p(m);
  for (int i = 0; i < m; ++i) cin >> p[i];
  int ans = 0;
  for (int bit = 1; bit < (1 << n); ++bit) {
    bool flag = true;
    for (int i = 0; i < m; i++) {
      int count = 0;
      for (int j = 0; j < (int)light[i].size(); ++j) {
        if ((bit >> light[i][j]) & 1) {
          count++;
        }
      }
      if (count % 2 != p[i]) {
        flag = false;
        continue;
      }
    }
    if (flag) ans++;
  }
  cout << ans << endl;
  return 0;
}
