#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  int cnt = 0, cnt2 = 0, cnt3 = 0;
  cin >> n >> m;
  vector<int> v2(m);
  vector<vector<int>> v(m, vector<int>(n));
  for (int i = 0; i < m; i++) {
    cin >> v2[i];
    for (int j = 0; j < v2[i]; j++) cin >> v[i][j];
  }
  vector<int> v3(m);
  for (int i = 0; i < m; i++) cin >> v3[i];
  for (int i = 0; i < (1 << n); i++) {
    bitset<11> b(i);
    for (int k = 0; k < m; k++) {
      for (int j = 0; j < v2[k]; j++) {
        if (b[v[k][j] - 1] == 1) cnt++;
      }
      if (cnt % 2 != v3[k]) cnt2++;
    }
    if (cnt2 == 0) cnt3++;
    cnt = 0, cnt2 = 0;
  }
  cout << cnt3 << endl;
}
