#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> s(m);
  vector<int> p;
  for (int i = 0; i < (m); ++i) {
    int k;
    cin >> k;
    for (int j = 0; j < (k); ++j) {
      int x;
      cin >> x;
      s[i].push_back(x);
    }
  }
  for (int i = 0; i < (n); ++i) {
    int x;
    cin >> x;
    p.push_back(x);
  }
  int sum = 1;
  for (int i = 0; i < (n); ++i) {
    sum *= 2;
  }
  for (int i = 0; i < (n); ++i) {
    int num = 1;
    for (int j = 0; j < (s[i].size()); ++j) {
      num *= 2;
    }
    sum -= num;
  }
  cout << sum << endl;
  return 0;
}
