#include <bits/stdc++.h>
const long long mod = 1e9 + 7;
const long long inf = 1e18;
using namespace std;
long long n, m;
long long k[11], s[11][11], p[11];
int main() {
  cin >> n >> m;
  for (long long i = 0; i < m; i++) {
    cin >> k[i];
    for (long long j = 0; j < k[i]; j++) cin >> s[i][j];
  }
  for (long long i = 0; i < m; i++) cin >> p[i];
  long long ans = 0;
  for (long long i = 0; i < 1 << n; i++) {
    long long cnt = 0;
    bool flag = true;
    for (long long j = 0; j < m; j++) {
      for (long long l = 0; l < k[j]; l++) {
        if (i & 1 << (s[j][l] - 1)) cnt++;
      }
      if (cnt % 2 != p[j]) {
        flag = false;
        break;
      }
    }
    if (flag) ans++;
  }
  cout << ans << endl;
  return 0;
}
