#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 < (int)(m); i++) {
    int k;
    cin >> k;
    s[i] = vector<int>(k);
    for (int j = 0; j < (int)(k); j++) cin >> s[i][j];
  }
  vector<int> p(m);
  for (int i = 0; i < (int)(m); i++) cin >> p[i];
  int ans = 0;
  for (int on = 0; on < (int)((1 << n)); on++) {
    bool flg = true;
    for (int i = 0; i < (int)(m); i++) {
      int sum = 0;
      for (int j = 0; j < (int)(m); j++) {
        sum += (on >> (s[i][j] - 1)) & 1;
      }
      if (sum % 2 != p[i]) flg = false;
    }
    ans += flg;
  }
  cout << ans << endl;
}
