#include <bits/stdc++.h>
using namespace std;
const int N = 4004;
int n, m, W, f[N], w[N], v[N], dp[N], tmp[N];
vector<int> a[N];
inline void read(int &x) {
  x = 0;
  char c = getchar();
  int f = 1;
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = 10 * x + c - '0';
    c = getchar();
  }
  x *= f;
}
inline int find(int x) {
  if (f[x] == x) return x;
  return f[x] = find(f[x]);
}
int main() {
  read(n);
  read(m);
  read(W);
  for (int i = 1; i <= n; i++) read(w[i]);
  for (int i = 1; i <= n; i++) read(v[i]), f[i] = i;
  while (m--) {
    int a, b;
    read(a);
    read(b);
    int x = find(a), y = find(b);
    f[x] = y;
  }
  for (int i = 1; i <= n; i++) a[find(i)].push_back(i);
  for (int i = 1; i <= n; i++) {
    int len = a[i].size();
    for (int k = 0; k <= W; k++) tmp[k] = dp[k];
    int s1 = 0, s2 = 0;
    for (int j = 0; j <= len - 1; j++) {
      int p = a[i][j];
      s1 += w[p];
      s2 += v[p];
      for (int k = w[p]; k <= W; k++)
        tmp[k] = ((tmp[k]) > (dp[k - w[p]] + v[p]) ? (tmp[k])
                                                   : (dp[k - w[p]] + v[p]));
    }
    for (int k = s1; k <= W; k++)
      tmp[k] = ((tmp[k]) > (dp[k - s1] + s2) ? (tmp[k]) : (dp[k - s1] + s2));
    memcpy(dp, tmp, sizeof(tmp));
  }
  int ans = 0;
  for (int i = 0; i <= W; i++) ans = ((ans) > (dp[i]) ? (ans) : (dp[i]));
  printf("%d", ans);
  return 0;
}
