#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007LL;
const long long INF = 1LL << 60;
using vll = vector<long long>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pair<long long, long long> = pair<long long, long long>;
int main() {
  long long n, m;
  cin >> n >> m;
  vvll s(m, vll(0));
  for (long long i = 0; i < (m); i++) {
    int k;
    cin >> k;
    for (int g = 0; g < k; g++) {
      long long j;
      cin >> j;
      s[i].push_back(j);
    }
  }
  long long ans = 0;
  vll p(m);
  for (long long i = 0; i < (m); i++) cin >> p[i];
  for (int bit = 0; bit < (1 << n); bit++) {
    for (int i = 0; i < m; i++) {
      long long h = 0;
      long long cu = 0;
      for (int j = 0; j < s[i].size(); j++) {
        if (bit & (1 << s[i][j] - 1)) cu++;
      }
      if (cu % 2 == p[i])
        h++;
      else
        break;
      if (h == m) ans++;
    }
  }
  cout << (ans) << endl;
}
