#include <bits/stdc++.h>
using namespace std;
vector<long long int> vll[11];
long long int num[200005];
int main(void) {
  long long int m, n, i, j, k = 1, d = 0, sum = 0, judge;
  string s, s1;
  cin >> n >> m;
  for (i = 0; i < m; i++) {
    cin >> k;
    for (j = 0; j < k; j++) {
      cin >> d;
      vll[i].push_back(d);
    }
  }
  for (i = 0; i < m; i++) cin >> num[i];
  for (i = 0; i < pow(2, n); i++) {
    for (j = 0; j < m; j++) {
      d = judge = 0;
      for (k = 0; k < vll[j].size(); k++)
        if ((i & vll[j][k]) == vll[j][k]) d++;
      if ((d & 1) != num[j]) {
        judge = 1;
        break;
      }
    }
    if (!judge) sum++;
  }
  cout << sum;
  return 0;
}
