#include <bits/stdc++.h>
using namespace std;
const int inf = 2e+9;
int w[1100], b[1100];
int pre[1100], vis[1100];
vector<pair<int, int> > f[1100];
int dp[1100];
vector<int> g[1100];
int findd(int k) {
  if (k != pre[k]) pre[k] = findd(pre[k]);
  return pre[k];
}
int main() {
  int n, W, m;
  cin >> n >> m >> W;
  for (int i = 0; i < n; ++i) {
    scanf("%d", &w[i]);
  }
  for (int i = 0; i < n; ++i) {
    scanf("%d", &b[i]);
  }
  for (int i = 0; i < n; ++i) pre[i] = i;
  int u, v, cnt, f1, f2;
  for (int i = 0; i < m; ++i) {
    scanf("%d%d", &u, &v);
    --u;
    --v;
    f1 = findd(u);
    f2 = findd(v);
    if (f1 != f2) pre[f1] = f2;
  }
  memset(vis, -1, sizeof(vis));
  cnt = 0;
  for (int i = 0; i < n; ++i) {
    f1 = findd(i);
    if (vis[f1] == -1) {
      vis[f1] = cnt++;
    }
    f[vis[f1]].push_back(make_pair(w[i], b[i]));
  }
  for (int i = 0; i < cnt; ++i) {
    if (f[i].size() > 1) f[i].push_back(make_pair(0, 0));
  }
  for (int i = 0; i < n; ++i) {
    f1 = findd(i);
    int j = f[vis[f1]].size();
    if (j == 1) continue;
    f[vis[f1]][j - 1].first += w[i];
    f[vis[f1]][j - 1].second += b[i];
  }
  int k, ans = 0;
  for (int i = 0; i < cnt; ++i) {
    int len = f[i].size();
    for (k = W; k >= 0; --k) {
      for (int j = 0; j < len; ++j) {
        if (k >= f[i][j].first) {
          dp[k] = max(dp[k], dp[k - f[i][j].first] + f[i][j].second);
          ans = max(ans, dp[k]);
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}
