#include <bits/stdc++.h>
using namespace std;
string onoff[1024];
int num;
void all(string str, int n) {
  if (n == 0)
    onoff[num++] = str;
  else if (n > 0) {
    all(str + "0", n - 1);
    all(str + "1", n - 1);
  }
}
int main() {
  int n, m;
  cin >> n >> m;
  int k[m];
  string s[m];
  int temp;
  all("", n);
  for (int i = 0; i < m; i++) {
    cin >> k[i];
    for (int j = 0; j < k[i]; j++) {
      cin >> temp;
      s[i].append(to_string(temp));
    }
  }
  int p[m];
  for (int i = 0; i < m; i++) {
    cin >> p[i];
  }
  int ans = 0;
  int flag = 1;
  for (int i = 0; i < num; i++) {
    for (int j = 0; j < m; j++) {
      int on = 0;
      for (int l = 0; l < k[j]; l++) {
        if (onoff[i][s[j][l] - '0' - 1] == '1') {
          on++;
        }
      }
      if (on % 2 != p[j]) {
        flag = 0;
        break;
      }
    }
    if (flag)
      ans++;
    else
      flag = 1;
  }
  cout << ans << endl;
  return 0;
}
