#define _LIBCPP_DEBUG 0
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,j,n) for(int i = j; i < n; i++)
#define rrep(i,j,n) for(int i = j-1; i >= n; i--)
#define prec(n) fixed << setprecision(n)
#define print_array(v) rep(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define acc(v) accumulate(v.begin(), v.end(),0);
#define MOD 1e+7;
#define inf 1e9;
#define fi first;
#define se second;
using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vector<int> p(m);
  vector<vector<int>> s(m,vector<int>(0));
  rep(i,m) {
    cin >> k;
    rep(j,k) {
      int a;
      cin >> a;
      a--;
      s[i].push_back(a);
    }
  }
  rep(i,m) cin >> p[i];
  for (int bit = 0; bit < (1 << n); bit++) {
    bool ok = true;
    rep(i,m) {
      int con = 0;
      for (auto v : s[i]) if (bit & (1 << v)) ++con;
      if (con % 2 != p[i]) ok = false;
    }
    if (ok) res++;
  }
  cout << res << endl;
  return 0;
}
//templete by private_yusuke