#include <bits/stdc++.h>
using namespace std;
inline void Fail() {
  printf("0");
  exit(0);
}
const int maxn = 20005;
int n, m, g, ans;
int tp[maxn], pan[maxn];
vector<int> v[maxn];
class max_flow {
 public:
  int s, t;
  class EDGE {
   public:
    int to, cap, rev;
    EDGE(int _to, int _cap, int _rev) {
      to = _to;
      cap = _cap;
      rev = _rev;
    }
  };
  vector<EDGE> edge[maxn];
  int level[maxn], nxt[maxn], q[maxn];
  void add_edge(int from, int to, int cap) {
    edge[from].push_back(EDGE(to, cap, edge[to].size()));
    edge[to].push_back(EDGE(from, 0, edge[from].size() - 1));
  }
  void bfs() {
    memset(level, -1, sizeof(level));
    int l = 0, r = 0;
    q[r++] = s;
    level[s] = 0;
    while (l < r) {
      int x = q[l++];
      for (int(i) = 0; (i) < edge[x].size(); i++) {
        EDGE y = edge[x][i];
        if (y.cap && level[y.to] < 0) {
          level[y.to] = level[x] + 1;
          q[r++] = y.to;
        }
      }
    }
  }
  int dfs(int x, int flow) {
    if (x == t) return flow;
    for (int &i = nxt[x]; i < edge[x].size(); i++) {
      EDGE &y = edge[x][i];
      if (y.cap && level[y.to] == level[x] + 1) {
        int d = dfs(y.to, min(flow, y.cap));
        if (d > 0) {
          y.cap -= d;
          edge[y.to][y.rev].cap += d;
          return d;
        }
      }
    }
    return 0;
  }
  int mf() {
    int flow = 0;
    for (;;) {
      bfs();
      if (level[t] < 0) return flow;
      memset(nxt, 0, sizeof(nxt));
      int f;
      while ((f = dfs(s, 1e9)) > 0) flow += f;
    }
  }
} M;
bool same(int i, int j) {
  for (int(ii) = 0; (ii) < v[i].size(); ii++)
    for (int(jj) = 0; (jj) < v[j].size(); jj++)
      if (v[i][ii] == v[j][jj]) return true;
  return false;
}
int main() {
  scanf("%d%d%d", &n, &m, &g);
  M.s = n + m;
  M.t = n + m + 1;
  for (int(i) = 0; (i) < n; i++) scanf("%d", &tp[i]);
  for (int(i) = 0; (i) < n; i++) scanf("%d", &pan[i]);
  for (int i = n; i < n + m; i++) {
    scanf("%d%d", &tp[i], &pan[i]);
    ans += pan[i];
    int k;
    scanf("%d", &k);
    while (k--) {
      int x;
      scanf("%d", &x);
      v[i].push_back(x - 1);
    }
    scanf("%d", &k);
    if (k) pan[i] += g;
  }
  for (int(i) = 0; (i) < n + m; i++) {
    if (!tp[i])
      M.add_edge(M.s, i, pan[i]);
    else
      M.add_edge(i, M.t, pan[i]);
  }
  for (int i = n; i < n + m; i++) {
    for (int(j) = 0; (j) < v[i].size(); j++) {
      if (!tp[i] && tp[v[i][j]]) M.add_edge(i, v[i][j], 1e9);
      if (tp[i] && !tp[v[i][j]]) M.add_edge(v[i][j], i, 1e9);
    }
    for (int j = i + 1; j < n + m; j++)
      if (same(i, j) && tp[i] != tp[j]) {
        if (!tp[i] && tp[j])
          M.add_edge(i, j, 1e9);
        else
          M.add_edge(j, i, 1e9);
      }
  }
  printf("%d", ans - M.mf());
  return 0;
}
