#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 20;
long long fa[N], n, b[N], w[N], W;
long long dp[N];
vector<int> group[N];
int find(int x) {
  if (fa[x] != x) {
    fa[x] = find(fa[x]);
  }
  return fa[x];
}
void Union(int x, int y) {
  int fx = find(x), fy = find(y);
  if (fx != fy) {
    fa[fx] = fy;
  }
}
void calc() {
  memset(dp, 0, sizeof(dp));
  for (int i = 1; i <= n; i++) {
    if (i != find(i)) continue;
    for (int j = W; j >= 0; j--) {
      long long sumb = 0, sumw = 0;
      for (int k = 0; k < group[i].size(); k++) {
        sumw += w[group[i][k]];
        sumb += b[group[i][k]];
        if (j >= w[group[i][k]]) {
          dp[j] = max(dp[j], dp[j - w[group[i][k]]] + b[group[i][k]]);
        }
      }
      if (j >= sumw) {
        dp[j] = max(dp[j], dp[j - sumw] + sumb);
      }
    }
  }
  cout << dp[W] << endl;
}
int main() {
  int m;
  cin >> n >> m >> W;
  for (int i = 1; i <= n; i++) {
    cin >> w[i];
    fa[i] = i;
  }
  for (int i = 1; i <= n; i++) cin >> b[i];
  for (int i = 1; i <= m; i++) {
    int x, y;
    cin >> x >> y;
    Union(x, y);
  }
  for (int i = 1; i <= n; i++) {
    group[find(i)].push_back(i);
  }
  calc();
  return 0;
}
