#include <bits/stdc++.h>
using namespace std;
const int N = 1003;
int n, m, wmax;
int groupCount;
int w[N];
int b[N];
int gid[N];
int st[N];
int fin[N];
int totB[N], totW[N];
vector<int> g[N];
bool visit[N];
int dp[N][N][2];
void dfs(int u) {
  gid[u] = groupCount;
  visit[u] = true;
  for (int v : g[u]) {
    if (!visit[v]) {
      dfs(v);
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n >> m >> wmax;
  for (int i = 0; i < n; i++) {
    cin >> w[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> b[i];
  }
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  for (int i = 0; i < n; i++) {
    if (!visit[i]) {
      groupCount++;
      dfs(i);
    }
  }
  vector<int> p(n);
  iota(begin(p), end(p), 0);
  sort(begin(p), end(p), [&](int i, int j) { return gid[i] < gid[j]; });
  memset(st, 0x3f, sizeof(st));
  memset(fin, 0, sizeof(fin));
  for (int i = 0; i < n; i++) {
    int who = p[i];
    int g = gid[who];
    st[g] = min(st[g], i);
    fin[g] = max(fin[g], i);
    totB[g] += b[who];
    totW[g] += w[who];
  }
  memset(dp, -1, sizeof(dp));
  dp[0][0][0] = 0;
  for (int i = 0; i < n; i++) {
    int who = p[i];
    int g = gid[who];
    for (int j = 0; j <= wmax; j++) {
      if (dp[i][j][0] != -1) {
        if (i == st[g]) {
          if (j + totW[g] <= wmax) {
            (dp[fin[g] + 1][j + totW[g]][0]) =
                max((dp[fin[g] + 1][j + totW[g]][0]), (dp[i][j][0] + totB[g]));
          }
        }
        if (i == fin[g]) {
          if (j + w[who] <= wmax) {
            (dp[i + 1][j + w[who]][0]) =
                max((dp[i + 1][j + w[who]][0]), (dp[i][j][0] + b[who]));
          }
        } else {
          if (j + w[who] <= wmax) {
            (dp[i + 1][j + w[who]][1]) =
                max((dp[i + 1][j + w[who]][1]), (dp[i][j][0] + b[who]));
          }
        }
        (dp[i + 1][j][0]) = max((dp[i + 1][j][0]), (dp[i][j][0]));
      }
      if (dp[i][j][1] != -1) {
        if (i == fin[g]) {
          (dp[i + 1][j][0]) = max((dp[i + 1][j][0]), (dp[i][j][1]));
        } else {
          (dp[i + 1][j][1]) = max((dp[i + 1][j][1]), (dp[i][j][1]));
        }
      }
    }
  }
  int ans = -1;
  for (int i = 0; i <= wmax; i++) {
    ans = max(ans, dp[n][i][0]);
  }
  cout << ans << endl;
  return 0;
}
