#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000;
int par[maxn + 10];
int n, m, w;
int weight[maxn + 10];
int beauty[maxn + 10];
int dp[maxn + 10][maxn + 10];
int seq[maxn + 10];
int root(int x) { return par[x] = (par[x] == x ? x : root(par[x])); }
bool sama(int x, int y) { return root(x) == root(y); }
void gabung(int x, int y) { par[root(x)] = par[root(y)]; }
bool cmp(int x, int y) { return root(x) < root(y); }
void setMaks(int &x, int y) { x = max(x, y); }
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  memset(dp, -1, sizeof dp);
  for (int i = 0; i < maxn; i++) {
    par[i] = i;
    seq[i] = i;
  }
  cin >> n >> m >> w;
  for (int i = 0; i < n; i++) {
    cin >> weight[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> beauty[i];
  }
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    gabung(x - 1, y - 1);
  }
  sort(seq, seq + n, cmp);
  int awal, sekarang;
  awal = sekarang = 0;
  int allSek = 0;
  int sumB = 0, sumW = 0;
  dp[0][w] = 0;
  while (sekarang <= n) {
    if (sekarang == n || root(seq[sekarang]) != root(seq[awal])) {
      if (allSek == 0) {
        if (sumW <= w) {
          setMaks(dp[allSek][w - sumW], sumB);
        }
      } else {
        for (int i = 0; i <= w; i++) {
          if (dp[allSek - 1][i] > -1) {
            setMaks(dp[allSek][i], dp[allSek - 1][i]);
            if (i >= sumW) {
              setMaks(dp[allSek][i - sumW], dp[allSek - 1][i] + sumB);
            }
          }
        }
      }
      allSek++;
      sumB = 0;
      sumW = 0;
      awal = sekarang;
    }
    if (sekarang < n) {
      sumB += beauty[seq[sekarang]];
      sumW += weight[seq[sekarang]];
      if (allSek == 0) {
        if (weight[seq[sekarang]] <= w) {
          setMaks(dp[allSek][w - weight[seq[sekarang]]], beauty[seq[sekarang]]);
        }
      } else {
        for (int i = 0; i <= w; i++) {
          if (dp[allSek - 1][i] > -1) {
            setMaks(dp[allSek][i], dp[allSek - 1][i]);
            if (i >= weight[seq[sekarang]]) {
              setMaks(dp[allSek][i - weight[seq[sekarang]]],
                      dp[allSek - 1][i] + beauty[seq[sekarang]]);
            }
          }
        }
      }
    }
    sekarang++;
  }
  int ans = -1;
  for (int i = 0; i <= w; i++) {
    setMaks(ans, dp[allSek - 1][i]);
  }
  cout << ans << endl;
}
