#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef double db;
typedef vector <ll> vll;
typedef pair <ll, ll> pll;
#define pb push_back
#define mp make_pair
#define MAX 1000000
#define mod 1000000007
#define all(_) _.begin(), _.end()
#define F first
#define S second
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

int main()
{
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);
    ll n, k, x, i, m, ans = 1;
    cin >> n >> m;
    ll a[m][2];
    for(ll y = 0; y < m; y++)
    {
        cin >> k;
        a[y][0] = k / 2;
        a[y][1] = (k + 1) / 2;
        for(i = 0; i < k; i++)
            cin >> x;
    }
    for(i = 0; i < m; i++)
    {
        cin >> x;
        ans *= a[i][x & 1];
    }
    cout << ans << endl;
    return 0;   
}