#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
using llong = long long;
using P = pair<int, int>;
const int inf = 1 << 20;
const int mod = 1e9 + 7;

int main() {
   int n, m;
   cin >> n >> m;
   vector<int> a(n);
   rep(i, m) {
      int k;
      cin >> k;
      rep(j, k) {
         int s;
         cin >> s;
         s--;
         a[s] |= 1 << i;
      }
   }
   rep(i, m) {
      int x;
      cin >> x;
      p |= x << i;
   }
   int ans = 0;
   rep(s, 1 << n) {
      int t = 0;
      rep(i, n) {
         if (s >> i & 1) {
            t ^= a[i];
         }
      }
      if (t == p) {
         ans++;
      }
   }
   cout << ans << endl;
   return 0;
}