#include <bits/stdc++.h>
using namespace std;
static const long long maxLL = (long long)1 << 62;
const long long MOD = 1000000007;
const long long INF = 1e18;
const double PI = 3.14159265359;
int ca[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
char A[10];
int cnt = 0;
vector<vector<int>> klist(100);
int n, m;
vector<int> plist;
vector<vector<bool>> flag2(100, vector<bool>(100, 0));
int ans = 0;
void binary(int nn) {
  if (nn < 1) {
    A[10 - 1] = '\0';
    int cnt3 = 0;
    for (int i = 0; i < m; i++) {
      int cnt2 = 0;
      for (int t = 0; t < n; t++) {
        if (A[t] == '1' && flag2[i][t] == true) {
          cnt2++;
        }
      }
      if (cnt2 % 2 == plist[i]) cnt3++;
      if (cnt3 == m) ans++;
    }
  } else {
    A[nn - 1] = '0';
    binary(nn - 1);
    A[nn - 1] = '1';
    binary(nn - 1);
  }
}
signed main() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int num;
    cin >> num;
    for (int j = 0; j < num; j++) {
      int num2;
      cin >> num2;
      klist[i].push_back(num2);
      flag2[i][num2 - 1] = true;
    }
  }
  for (int i = 0; i < m; i++) {
    int num;
    cin >> num;
    plist.push_back(num);
  }
  binary(n);
  cout << ans << endl;
  getchar();
  getchar();
  return 0;
}
