#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
const long long l_INF = 1010101010101010;
const int INF = 1010101010;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};
using vi = vector<int>;
using vll = vector<long long>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
int main() {
  int n, m;
  cin >> n >> m;
  vi k(m);
  vi p(m);
  vector<set<int>> s(m);
  for (int i = 0; i < m; i++) {
    cin >> k[i];
    for (int j = 0; j < k[i]; j++) {
      int in;
      cin >> in;
      s[i].insert(in);
    }
  }
  vi sum(m);
  int count = 0;
  for (int i = 0; i < m; i++) cin >> p[i];
  for (int i = 0; i < 1 << n; i++) {
    for (int i_1 = 0; i_1 < m; i_1++) {
      for (int j = 0; j < n; j++) {
        if (((i >> j) & 1) && s[i_1].count(j + 1)) sum[i_1]++;
      }
    }
    bool judge = true;
    for (int i_2 = 0; i_2 < m; i_2++) {
      if (sum[i_2] % 2 != p[i_2]) judge = false;
    }
    if (judge) count++;
  }
  cout << count;
}
