#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;
const int MX = 2005;
const double pi = 3.141592653589793238;
int N, M;
int k[15], s[15][15], p[15];
int cnt;
bool ans;
int many;
int main() {
  cin >> N >> M;
  for (int i = 1; i <= (M); ++i) {
    cin >> k[i];
    for (int j = 1; j <= (k[i]); ++j) cin >> s[i][j];
  }
  for (int i = 1; i <= (M); ++i) cin >> p[i];
  many = 0;
  for (int bit = 0; bit < (1 << N); ++bit) {
    ans = true;
    for (int i = 1; i <= (M); ++i) {
      cnt = 0;
      for (int j = 1; j <= (k[i]); ++j)
        if (bit & (1 << j)) cnt += 1;
      if (cnt % 2 != p[i]) {
        ans = false;
        break;
      }
    }
    if (ans) many += 1;
  }
  cout << many << endl;
}
