#include <bits/stdc++.h>
using namespace std;
class zahyo {
 public:
  int x;
  int y;
  zahyo() {
    x = 0;
    y = 0;
  }
  zahyo(int x_, int y_) {
    x = x_;
    y = y_;
  }
  void print() { cout << x << " " << y; }
  zahyo operator+(zahyo add) {
    add.x = this->x + add.x;
    add.y = this->y + add.y;
    return add;
  }
  zahyo operator-(zahyo add) {
    add.x = this->x - add.x;
    add.y = this->y - add.y;
    return add;
  }
  bool operator==(const zahyo add) const {
    if (add.x == this->x and add.y == this->y) {
      return true;
    } else {
      return false;
    }
  }
  bool operator!=(const zahyo add) const {
    if (add.x == this->x or add.y == this->y) {
      return false;
    } else {
      return true;
    }
  }
  bool operator<(const zahyo add) const {
    if (this->x < add.x) {
      return true;
    } else if (this->x == add.x and this->y < add.y) {
      return true;
    } else {
      return false;
    }
  }
  bool operator>(const zahyo add) const {
    if (this->x > add.x) {
      return true;
    } else if (this->x == add.x and this->y > add.y) {
      return true;
    } else {
      return false;
    }
  }
  void input() { cin >> x >> y; }
};
int main() {
  int n, m;
  cin >> n >> m;
  int s[10];
  for (int i = 0; i < m; i++) {
    int k;
    cin >> k;
    s[i] = 0;
    for (int j = 0; j < k; j++) {
      int s_;
      cin >> s_;
      s[i] = s[i] | (1 << s_);
    }
  }
  int p[10];
  for (int i = 0; i < m; i++) {
    cin >> p[i];
  }
  int ans = 0;
  for (int i = 0; i < (1 << n); i++) {
    bool ok = true;
    for (int j = 0; j < m; j++) {
      int temp = i & s[j];
      int check = 0;
      while (temp) {
        check += temp % 2;
        temp = temp >> 1;
      }
      if (check % 2 != p[j]) {
        ok = false;
      }
    }
    if (ok) {
      ans++;
    }
  }
  cout << ans << endl;
}
