#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> S(m);
  for (int i = 0; i < m; ++i) {
    int k;
    cin >> k;
    for (int j = 0; j < k; ++j) cin >> S[i][j];
  }
  vector<int> p(m);
  for (int i = 0; i < m; ++i) cin >> p[i];
  int ans = 0;
  for (int i = 0; i < (1 << 10); ++i) {
    bool r = true;
    bitset<10> b(i);
    for (int j = 0; j < m; ++j) {
      int sum = 0;
      for (int s : S[j]) {
        if (b.test(s)) sum++;
      }
      if (sum % 2 != p[j]) {
        r = false;
        break;
      }
    }
    if (r) ans++;
  }
  cout << ans << endl;
}
