#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e3 + 17;
const int MOD = 1e9 + 7;
int fth[MAXN], f[2][MAXN], vis[MAXN];
vector<int> grp[1003];
int fd(int x) { return fth[x] == x ? x : fth[x] = fd(fth[x]); }
void unite(int x, int y) { fth[fd(y)] = fd(x); }
int main(int argc, char const *argv[]) {
  int n, m, mw;
  cin >> n >> m >> mw;
  vector<pair<int, int> > vec(n), dt;
  for (int i = 0; i < n; ++i) {
    fth[i] = i;
    cin >> vec[i].first;
  };
  for (int i = 0; i < n; ++i) {
    cin >> vec[i].second;
  }
  for (int i = 0; i < m; ++i) {
    int u, v;
    cin >> u >> v;
    --u, --v;
    unite(u, v);
  }
  map<int, int> mp;
  int k = 1;
  for (int i = 0; i < n; ++i) {
    if (!mp[fd(i)]) mp[fd(i)] = k++;
    grp[mp[fd(i)] - 1].push_back(i);
  }
  dt.resize(k - 1);
  for (int i = 0; i < k - 1; ++i) {
    dt[i].first = dt[i].second = 0;
    for (auto j : grp[i]) {
      dt[i].first += vec[j].first;
      dt[i].second += vec[j].second;
    }
  }
  int now = 0, pre = 1, ans = 0;
  for (int i = 0; i < n; ++i) {
    if (vis[fd(i)]) continue;
    vis[fd(i)] = 1;
    ;
    ;
    ;
    swap(now, pre);
    for (int j = 0; j <= mw; ++j) f[now][j] = f[pre][j];
    for (auto k : grp[mp[fd(i)] - 1]) {
      ;
      for (int j = 0; j <= mw; ++j) {
        if (j >= vec[k].first) {
          ;
          ;
          ;
          ;
          f[now][j] = max(f[now][j], f[pre][j - vec[k].first] + vec[k].second);
          ;
        }
        ans = max(ans, f[now][j]);
      }
      for (int j = 0; j <= mw; ++j) {
        if (j >= dt[mp[fd(i)] - 1].first)
          f[now][j] = max(f[now][j], f[pre][j - dt[mp[fd(i)] - 1].first] +
                                         dt[mp[fd(i)] - 1].second);
        ans = max(ans, f[now][j]);
      }
    }
  }
  cout << ans << endl;
  return 0;
}
