#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> s(m);
  vector<int> p(m);
  for (long long i = 0; i < (m); ++i) {
    int k;
    cin >> k;
    for (long long i = 0; i < (k); ++i) {
      int temp;
      cin >> temp;
      temp--;
      s[i].emplace_back(temp);
    }
  }
  for (long long i = 0; i < (m); ++i) cin >> p[i];
  int ans = 0;
  int cnt = 0;
  for (int b = 0; b < (1 << n); b++) {
    for (long long i = 0; i < (m); ++i) {
      int now = 0;
      for (auto t : s[i]) {
        if (b & (1 << t)) now++;
      }
      if (now % 2 != p[i]) {
        cnt = -1;
        break;
      }
    }
    if (cnt != -1) ans++;
    cnt = 0;
  }
  cout << ans;
}
