#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
int n, m, k[15], q[15], a[15][15];
map<int, int> bulb;
int ans;
int main() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> k[i];
    for (int j = 0; j < k[i]; j++) cin >> a[i][j], bulb[i] = a[i][j] - 1;
  }
  for (int i = 0; i < m; i++) cin >> q[i];
  for (int i = 0; i < (1 << n); i++) {
    int b[15];
    memset(b, 0, sizeof(b));
    for (int j = 0; j < n; j++) b[j] = (i & (1 << j) ? 1 : 0);
    vector<int> s[15];
    for (int j = 0; j < n; j++)
      if (b[j]) s[j].push_back(bulb[j]);
    bool flag = 0;
    for (int j = 0; j < n; j++)
      if (s[j].size() % 2 != q[j]) {
        flag = 1;
        break;
      }
    if (!flag) ans++;
  }
  cout << ans;
  return 0;
}
