#include <bits/stdc++.h>
using namespace std;
vector<int> g[1010];
vector<vector<int>> cc;
int u[1010];
void dfs(int v) {
  u[v] = 1;
  cc.back().push_back(v);
  for (int to : g[v]) {
    if (!u[to]) dfs(to);
  }
}
int main() {
  int n, m, maxW;
  cin >> n >> m >> maxW;
  int w[1010];
  for (int i = 0; i < n; i++) {
    cin >> w[i];
  }
  int b[1010];
  for (int i = 0; i < n; i++) {
    cin >> b[i];
  }
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  for (int i = 0; i < n; i++) {
    if (!u[i]) {
      cc.push_back(vector<int>());
      dfs(i);
    }
  }
  int d[2][1010] = {};
  for (int i = 0; i < cc.size(); i++) {
    int sw = 0, sb = 0;
    for (int j = 0; j < cc[i].size(); j++) {
      sw += w[cc[i][j]];
      sb += b[cc[i][j]];
      for (int wi = w[cc[i][j]]; wi <= maxW; wi++) {
        d[1][wi] = max(d[1][wi], d[0][wi - w[cc[i][j]]] + b[cc[i][j]]);
      }
    }
    for (int wi = sw; wi <= maxW; wi++) {
      d[1][wi] = max(d[1][wi], d[0][wi - sw] + sb);
    }
    for (int i = 0; i <= maxW; i++) {
      d[0][i] = max(d[0][i], d[1][i]);
      d[1][i] = 0;
    }
  }
  cout << *max_element(d[0], d[0] + maxW + 1);
}
