#include <bits/stdc++.h>
using ll = unsigned long long;
using namespace std;
int main(void) {
  int n, m;
  cin >> n >> m;
  int *k, *p;
  int **s;
  k = new int[m];
  p = new int[m];
  s = new int *[m];
  for (int i = 0; i < m; ++i) {
    s[i] = new int[m];
  }
  for (int o = 0; o < m; ++m) {
    for (int i = 0; i < m + 1; ++i) {
      if (i == 0) {
        cin >> k[i];
      } else {
        cin >> s[o][i - 1];
      }
    }
  }
  for (int i = 0; i < m; ++i) {
    cin >> p[i];
  }
  ll res = 0;
  for (int bit = 0; bit < (1 << n); ++bit) {
    bool turnon = true;
    for (int i = 0; i < m; ++i) {
      int sumv = 0;
      for (int si = 0; si < m; ++si) {
        if (bit & (1 << s[i][si])) {
          ++sumv;
        }
      }
      if (sumv % 2 != p[i]) {
        turnon = false;
      }
    }
    if (turnon) {
      res++;
    }
  }
  cout << res << endl;
  return 0;
}
