#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int MAX = 2 * 10e5 + 2;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, M;
  while (cin >> N >> M) {
    int ans = 0;
    vector<tuple<string, int, int>> ress;
    vector<int> k(M);
    vector<vector<int>> ss(M);
    vector<int> p(M);
    for (int(i) = 0; (i) < (M); (i)++) {
      cin >> k[i];
      for (int(j) = 0; (j) < (k[i]); (j)++) {
        int s;
        cin >> s;
        s--;
        ss[i].push_back(s);
      }
    }
    for (int(i) = 0; (i) < (M); (i)++) {
      cin >> p[i];
    }
    int swi = N;
    vector<int> pow2(N + 1);
    pow2[0] = 1;
    for (int(i) = 0; (i) < (N); (i)++) {
      pow2[i + 1] = pow2[i] * 2;
    }
    for (int(i) = 0; (i) < (pow(2, N - 2)); (i)++) {
      int lit = 0;
      for (int(k) = 0; (k) < (M); (k)++) {
        int cnt = 0;
        for (typeof((ss[k]).begin()) j = (ss[k]).begin(); j != (ss[k]).end();
             ++j) {
          int cur = i & (pow2[*j + 1]);
          cnt++;
        }
        if (cnt % 2 == p[k] && cnt != 0) lit++;
      }
      cerr << "lit"
           << " = " << (lit) << " (L" << 77 << ")"
           << " "
           << "<stdin>" << endl;
      if (lit == M) ans++;
    }
    cout << ans << endl;
  }
  return 0;
}
