#include <bits/stdc++.h>
using namespace std;
const int MAXN = 10000 * 2 + 10, INF = 0x3f3f3f3f;
struct Graph {
  int id, next, g;
} g[MAXN * 10 * 2];
int n, m, co, tot, S, T, Tohka, st[MAXN], dis[MAXN], num[MAXN], sex[MAXN];
void Add(int first, int second, int G) {
  g[tot].id = second, g[tot].g = G, g[tot].next = st[first], st[first] = tot++;
  g[tot].id = first, g[tot].g = 0, g[tot].next = st[second], st[second] = tot++;
}
void init() {
  scanf("%d%d%d", &n, &m, &co);
  S = 0, T = n + m + 1;
  memset(st, -1, sizeof(st));
  for (int i = 1; i <= n; ++i) scanf("%d", &sex[i]);
  for (int i = 1; i <= n; ++i) {
    int v;
    scanf("%d", &v);
    if (!sex[i])
      Add(S, i, v);
    else
      Add(i, T, v);
  }
  for (int i = 1; i <= m; ++i) {
    int sexc, k, w;
    scanf("%d%d%d", &sexc, &w, &k);
    for (int j = 1; j <= k; ++j) {
      int id;
      scanf("%d", &id);
      if (!sexc)
        Add(n + i, id, INF);
      else
        Add(id, n + i, INF);
    }
    int second;
    scanf("%d", &second);
    Tohka += w;
    if (!sexc)
      Add(S, n + i, w + second * co);
    else
      Add(n + i, T, w + second * co);
  }
}
int SAP(int first, int S, int T, int flow) {
  if (first == T) return flow;
  int res = flow;
  for (int i = st[first]; i != -1; i = g[i].next)
    if (g[i].g > 0 && dis[first] == dis[g[i].id] + 1) {
      int F = SAP(g[i].id, S, T, min(res, g[i].g));
      g[i].g -= F, g[i ^ 1].g += F, res -= F;
      if (res <= 0) return flow;
    }
  --num[dis[first]];
  if (!num[dis[first]]) dis[S] = T + 1;
  ++dis[first];
  ++num[dis[first]];
  return flow - res;
}
int Maxflow(int S, int T) {
  memset(num, 0, sizeof(num));
  memset(dis, 0, sizeof(dis));
  int Tohka = 0;
  for (num[0] = T + 1; dis[S] < T + 1; Tohka += SAP(S, S, T, INF))
    ;
  return Tohka;
}
void solve() { cout << Tohka - Maxflow(S, T) << endl; }
int main() {
  init();
  solve();
  fclose(stdin);
  fclose(stdout);
  return 0;
}
