#include <bits/stdc++.h>
using namespace std;
const int maxN = 1111;
vector<int> groups[maxN], edge[maxN];
int weight[maxN], beauty[maxN];
int n, m, w;
int ngroups;
int is_visited[maxN];
void bfs(int u) {
  groups[ngroups].push_back(u);
  int l = 0;
  int r = 1;
  is_visited[u] = true;
  while (l < r) {
    int u = groups[ngroups][l++];
    for (int i = 0; i < (int)edge[u].size(); i++) {
      int v = edge[u][i];
      if (is_visited[v]) continue;
      groups[ngroups].push_back(v);
      is_visited[v] = true;
      r++;
    }
  }
  ngroups++;
}
int dp[maxN][maxN];
int main() {
  cin >> n >> m >> w;
  for (int i = 1; i <= n; i++) scanf("%d", weight + i);
  for (int i = 1; i <= n; i++) scanf("%d", beauty + i);
  for (int i = 0; i < m; i++) {
    int u, v;
    scanf("%d %d", &u, &v);
    edge[u].push_back(v);
    edge[v].push_back(u);
  }
  for (int i = 1; i <= n; i++)
    if (!is_visited[i]) bfs(i);
  int total_weight = 0, total_beauty = 0;
  for (int i = 0; i < (int)groups[0].size(); i++) {
    int x = groups[0][i];
    dp[0][weight[x]] = max(dp[0][weight[x]], beauty[x]);
    total_weight += weight[x];
    total_beauty += beauty[x];
  }
  if (total_weight <= w)
    dp[0][total_weight] = max(dp[0][total_weight], total_beauty);
  for (int i = 1; i < ngroups; i++) {
    for (int j = 0; j <= w; j++) {
      total_weight = total_beauty = 0;
      dp[i][j] = dp[i - 1][j];
      for (int e = 0; e < (int)groups[i].size(); e++) {
        int x = groups[i][e];
        total_weight += weight[x];
        total_beauty += beauty[x];
        if (weight[x] <= j && dp[i - 1][j - weight[x]]) {
          dp[i][j] = max(dp[i][j], dp[i - 1][j - weight[x]] + beauty[x]);
        }
      }
      if (total_weight <= j && dp[i - 1][j - total_weight])
        dp[i][j] = max(dp[i][j], dp[i - 1][j - total_weight] + total_beauty);
    }
    total_weight = total_beauty = 0;
    for (int j = 0; j < (int)groups[i].size(); j++) {
      int x = groups[i][j];
      if (weight[x] <= w) dp[i][weight[x]] = max(dp[i][weight[x]], beauty[x]);
      total_weight += weight[x];
      total_beauty += beauty[x];
    }
    if (total_weight <= w)
      dp[i][total_weight] = max(dp[i][total_weight], total_beauty);
  }
  int res = 0;
  for (int i = 0; i <= w; i++) res = max(res, dp[ngroups - 1][i]);
  cout << res;
  return 0;
}
