#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> t(m, vector<int>(m + 1));
  vector<int> p(m);
  for (int i = 0; i < (int)(m); i++) {
    cin >> t[i][0];
    for (int j = 0; j < (int)(t[i][0]); j++) {
      cin >> t[i][j + 1];
    }
  }
  for (int i = 0; i < (int)(m); i++) cin >> p[i];
  int ans = 0;
  for (int b = 0; b < (int)((1 << n)); b++) {
    vector<int> sn(n, 0);
    bool ON = false;
    for (int i = 0; i < (int)(n); i++)
      if (b & (1 << i)) sn[i] = 1;
    for (int i = 0; i < (int)(m); i++) {
      int sum = 0;
      for (int j = 0; j < (int)(t[i][0]); j++) {
        sum += sn[t[i][j + 1] - 1];
      }
      if (sum % 2 == p[i])
        ON = true;
      else {
        ON = false;
        break;
      }
    }
    if (ON) ans++;
  }
  cout << ans << endl;
}
