#include <bits/stdc++.h>
using namespace std;
string bit(long long n, long long k) {
  string b = "";
  for (long long i = (long long)0; i < (long long)k; i++) {
    b += to_string(n % 2);
    n /= 2;
  }
  return b;
}
bool check(string b, long long s[], long long p) {
  long long count = 0;
  bool ans;
  for (long long i = (long long)0;
       i < (long long)sizeof(*s) / sizeof(long long); i++) {
    if (b[s[i] - 1] == '1') count++;
  }
  if (count % 2 == p) {
    return true;
  } else
    return false;
}
int main() {
  long long n, m, count = 0;
  long long s[11][11] = {};
  long long p[11] = {};
  cin >> n >> m;
  for (long long i = (long long)0; i < (long long)m; i++) {
    cin >> s[i][0];
    for (long long j = (long long)0; j < (long long)s[i][0]; j++) {
      cin >> s[i][j + 1];
    }
  }
  for (long long i = (long long)0; i < (long long)m; i++) cin >> p[i];
  for (long long i = (long long)0; i < (long long)pow(2, n); i++) {
    string b = bit(i, n);
    bool flag = true;
    for (long long j = (long long)0; j < (long long)m; j++) {
      if (check(b, s[j], p[j]) == false) {
        flag = false;
        break;
      }
    }
    if (flag == true) count++;
  }
  cout << count << endl;
  ;
  return 0;
}
