#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> k(m);
  vector<vector<int>> s(m, vector<int>(10));
  int tmp;
  int i, j;
  for (i = 0; i < m; i++) {
    cin >> k[i];
    for (j = 0; j < k[i]; j++) {
      cin >> tmp;
      s[i][tmp - 1] = 1;
    }
  }
  vector<int> p(m);
  for (i = 0; i < m; i++) {
    cin >> p[i];
  }
  int onoff = 0, ans = 0;
  int a, b, c, d, e, f, g, h, l;
  int y;
  for (a = 0; a < 2; a++) {
    for (b = 0; b < 2; b++) {
      if (n < 2 && b == 1) {
        break;
      }
      for (c = 0; c < 2; c++) {
        if (n < 3 && c == 1) {
          break;
        }
        for (d = 0; d < 2; d++) {
          if (n < 4 && d == 1) {
            break;
          }
          for (e = 0; e < 2; e++) {
            if (n < 5 && e == 1) {
              break;
            }
            for (f = 0; f < 2; f++) {
              if (n < 6 && f == 1) {
                break;
              }
              for (g = 0; g < 2; g++) {
                if (n < 7 && g == 1) {
                  break;
                }
                for (h = 0; h < 2; h++) {
                  if (n < 8 && h == 1) {
                    break;
                  }
                  for (i = 0; i < 2; i++) {
                    if (n < 9 && i == 1) {
                      break;
                    }
                    for (j = 0; j < 2; j++) {
                      if (n < 10 && j == 1) {
                        break;
                      }
                      y = 0;
                      onoff = a * s[l][0] + b * s[l][1] + c * s[l][2] +
                              d * s[l][3] + e * s[l][4] + f * s[l][5] +
                              g * s[l][6] + h * s[l][7] + i * s[l][8] +
                              j * s[l][9];
                      cerr << 1 << endl;
                      for (l = 0; l < m; l++) {
                        if (onoff % 2 == p[l]) {
                          y++;
                        }
                        cerr << 2 << endl;
                      }
                      if (y == m) {
                        ans++;
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
  cout << ans << endl;
}
