#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 5;
struct sa {
  int num;
  int s[15];
} a[15];
int main() {
  int n, m, k;
  int light[15];
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    cin >> k;
    a[i].num = k;
    for (int j = 1; j <= k; j++) {
      cin >> a[i].s[j];
    }
  }
  for (int i = 1; i <= m; i++) {
    cin >> light[i];
  }
  int count1 = 0;
  for (int i = 0; i < (1 << m); i++) {
    int compre[15];
    memset(compre, 0, sizeof(compre));
    for (int j = 0; j < m; j++) {
      if ((1 << j) & i) {
        for (int tt = 1; tt <= a[j + 1].num; tt++) {
          compre[a[j + 1].s[tt]]++;
        }
      }
    }
    int judge1 = 1;
    for (int tt = 1; tt <= m; tt++) {
      if (compre[tt] % 2 != light[tt]) {
        judge1 = 0;
        break;
      }
    }
    if (judge1 == 1) count1++;
  }
  cout << count1 << endl;
  return 0;
}
