#include <bits/stdc++.h>
using namespace std;
int is_friend[10000 + 5], sat_cost[10000 + 5], status[10000 + 5],
    want[10000 + 5];
vector<int> expect[10000 + 5];
const int INF = 0x7f7f7f7f;
int src, snk, nNode, nEdge;
int Q[100000 + 5], fin[100000 + 5], pro[100000 + 5], dist[100000 + 5];
int flow[2 * 100000 + 5], cap[2 * 100000 + 5], nxt[2 * 100000 + 5],
    to[2 * 100000 + 5];
void init(int _src, int _snk, int _n) {
  src = _src, snk = _snk, nNode = _n, nEdge = 0;
  memset(fin, -1, sizeof(fin));
}
void add_edge(int u, int v, int c) {
  to[nEdge] = v, cap[nEdge] = c, flow[nEdge] = 0, nxt[nEdge] = fin[u],
  fin[u] = nEdge++;
  to[nEdge] = u, cap[nEdge] = 0, flow[nEdge] = 0, nxt[nEdge] = fin[v],
  fin[v] = nEdge++;
  assert(nEdge <= 2 * 100000);
}
bool bfs() {
  int st, en, i, u, v;
  memset(dist, -1, sizeof(dist));
  dist[src] = st = en = 0;
  Q[en++] = src;
  while (st < en) {
    u = Q[st++];
    for (i = fin[u]; i >= 0; i = nxt[i]) {
      v = to[i];
      if (flow[i] < cap[i] && dist[v] == -1) {
        dist[v] = dist[u] + 1;
        Q[en++] = v;
      }
    }
  }
  return dist[snk] != -1;
}
int dfs(int u, int fl) {
  if (u == snk) return fl;
  for (int &e = pro[u], v, df; e >= 0; e = nxt[e]) {
    v = to[e];
    if (flow[e] < cap[e] && dist[v] == dist[u] + 1) {
      df = dfs(v, min(cap[e] - flow[e], fl));
      if (df > 0) {
        flow[e] += df;
        flow[e ^ 1] -= df;
        return df;
      }
    }
  }
  return 0;
}
long long int dinitz() {
  long long int ret = 0;
  int df;
  while (bfs()) {
    for (int i = 1; i <= nNode; i++) pro[i] = fin[i];
    while (true) {
      df = dfs(src, INF);
      if (df)
        ret += (long long int)df;
      else
        break;
    }
  }
  return ret;
}
int c[10000 + 5];
int main() {
  int i, n, m, g, j, k, v, ttl = 0;
  scanf("%d %d %d", &n, &m, &g);
  for (i = 1; i <= n; i++) scanf("%d", &status[i]);
  for (i = 1; i <= n; i++) scanf("%d", &c[i]);
  for (i = 1; i <= m; i++) {
    scanf("%d", &want[i]);
    scanf("%d", &sat_cost[i]);
    scanf("%d", &k);
    ttl += sat_cost[i];
    for (j = 1; j <= k; j++) {
      scanf("%d", &v);
      expect[i].push_back(v);
    }
    assert(scanf("%d", &is_friend[i]) == 1);
  }
  src = n + m + 1;
  snk = src + 1;
  init(src, snk, snk);
  for (i = 1; i <= n; i++) {
    if (status[i] == 1)
      add_edge(i, snk, c[i]);
    else
      add_edge(src, i, c[i]);
  }
  for (i = 1; i <= m; i++) {
    if (want[i] == 1) {
      for (auto x : expect[i]) add_edge(x, i + n, INF);
      add_edge(i + n, snk, sat_cost[i] + (is_friend[i] == true ? g : 0));
    } else {
      for (auto x : expect[i]) add_edge(i + n, x, INF);
      add_edge(src, i + n, sat_cost[i] + (is_friend[i] == true ? g : 0));
    }
  }
  cout << ttl - dinitz() << endl;
  return 0;
}
