Just to remind, girls in Arpa's land are really nice.

Mehrdad wants to invite some Hoses to the palace for a dancing party. Each Hos has some weight wi and some beauty bi. Also each Hos may have some friends. Hoses are divided in some friendship groups. Two Hoses x and y are in the same friendship group if and only if there is a sequence of Hoses a1, a2, ..., ak such that ai and ai + 1 are friends for each 1 ≤ i < k, and a1 = x and ak = y.

<image>

Arpa allowed to use the amphitheater of palace to Mehrdad for this party. Arpa's amphitheater can hold at most w weight on it. 

Mehrdad is so greedy that he wants to invite some Hoses such that sum of their weights is not greater than w and sum of their beauties is as large as possible. Along with that, from each friendship group he can either invite all Hoses, or no more than one. Otherwise, some Hoses will be hurt. Find for Mehrdad the maximum possible total beauty of Hoses he can invite so that no one gets hurt and the total weight doesn't exceed w.

Input

The first line contains integers n, m and w (1 ≤ n ≤ 1000, <image>, 1 ≤ w ≤ 1000) — the number of Hoses, the number of pair of friends and the maximum total weight of those who are invited.

The second line contains n integers w1, w2, ..., wn (1 ≤ wi ≤ 1000) — the weights of the Hoses.

The third line contains n integers b1, b2, ..., bn (1 ≤ bi ≤ 106) — the beauties of the Hoses.

The next m lines contain pairs of friends, the i-th of them contains two integers xi and yi (1 ≤ xi, yi ≤ n, xi ≠ yi), meaning that Hoses xi and yi are friends. Note that friendship is bidirectional. All pairs (xi, yi) are distinct.

Output

Print the maximum possible total beauty of Hoses Mehrdad can invite so that no one gets hurt and the total weight doesn't exceed w.

Examples

Input

3 1 5
3 2 5
2 4 2
1 2


Output

6


Input

4 2 11
2 4 6 6
6 4 2 1
1 2
2 3


Output

7

Note

In the first sample there are two friendship groups: Hoses {1, 2} and Hos {3}. The best way is to choose all of Hoses in the first group, sum of their weights is equal to 5 and sum of their beauty is 6.

In the second sample there are two friendship groups: Hoses {1, 2, 3} and Hos {4}. Mehrdad can't invite all the Hoses from the first group because their total weight is 12 > 11, thus the best way is to choose the first Hos from the first group and the only one from the second group. The total weight will be 8, and the total beauty will be 7.
#include <bits/stdc++.h>
namespace XX {
template <template <typename> class Compare, typename T>
inline T& UP(T& x, const T& y) {
  if (Compare<T>()(y, x)) x = y;
  return x;
}
template <typename Compare, typename T>
inline T& UP(T& x, const T& y, Compare comp) {
  if (comp(y, x)) x = y;
  return x;
}
template <typename T>
inline T& GT(T& x, const T& y) {
  return UP<std::greater>(x, y);
}
template <typename T>
inline T& LS(T& x, const T& y) {
  return UP<std::less>(x, y);
}
template <typename T>
struct Mapper {
  int operator[](const T& v) {
    int& ret = table[v];
    if (!ret) rtable[ret = table.size()] = v;
    return ret - 1;
  }
  template <typename... Args>
  int operator()(Args... args) {
    return (*this)[T(args...)];
  }
  T rev(int idx) { return rtable[idx + 1]; }
  std::map<T, int> table;
  std::map<int, T> rtable;
};
template <typename T, int S>
struct ReferenceArray {
  struct It {
    typename std::array<T*, S>::iterator it;
    T& operator*() { return **it; }
    void operator++() { it++; }
    bool operator!=(const It& other) { return it != other.it; }
  };
  int size() const { return _ptr.size(); }
  It begin() const { return {_ptr.begin()}; }
  It end() const { return {_ptr.end()}; }
  T& operator[](int idx) const { return *_ptr[idx]; }
  mutable std::array<T*, S> _ptr;
};
template <typename T, typename... Args>
ReferenceArray<T, sizeof...(Args) + 1> MAKEV(T& arg1, Args&... args) {
  return {&arg1, &args...};
}
struct Range {
  struct It {
    int num, step;
    int operator*() { return num; }
    void operator++() { num += step; }
    bool operator!=(const It& other) { return num != other.num; }
  };
  Range(int ee) : b(0), e(ee) {}
  Range(int bb, int ee) : b(bb), e(ee) {}
  It begin() { return {b, (b < e ? 1 : -1)}; }
  It end() { return {e, 0}; }
  int b, e;
};
}  // namespace XX
namespace XX {
template <typename... Datas>
struct UnionFind {
  struct Node : public Datas... {
    int _parent = -1;
    void operator+=(Node& other) {
      int dummy[] = {(Datas::operator+=(other), 0)...};
    }
  };
  UnionFind(int size) : _data(size) {}
  Node& operator[](int idx) { return _data[(*this)(idx)]; }
  int operator()(int n) {
    if (_data[n]._parent < 0)
      return n;
    else
      return _data[n]._parent = (*this)(_data[n]._parent);
  }
  bool operator()(int a, int b) {
    int pa = (*this)(a), pb = (*this)(b);
    if (pa == pb)
      return false;
    else {
      if (_data[pa]._parent == _data[pb]._parent)
        _data[pa]._parent--;
      else if (_data[pa]._parent > _data[pb]._parent)
        std::swap(pa, pb);
      _data[pa] += _data[pb];
      _data[pb]._parent = pa;
      return true;
    }
  }
  std::vector<Node> _data;
};
}  // namespace XX
template <typename T>
struct ScanfSpecifier {};
template <>
struct ScanfSpecifier<char*> {
  static constexpr const char* value = "%s";
};
template <>
struct ScanfSpecifier<int> {
  static constexpr const char* value = "%d";
};
template <>
struct ScanfSpecifier<double> {
  static constexpr const char* value = "%lf";
};
template <>
struct ScanfSpecifier<float> {
  static constexpr const char* value = "%f";
};
template <>
struct ScanfSpecifier<char> {
  static constexpr const char* value = "%c";
};
template <>
struct ScanfSpecifier<const char*> {
  static constexpr const char* value = "%s";
};
template <>
struct ScanfSpecifier<unsigned long> {
  static constexpr const char* value = "%lu";
};
template <>
struct ScanfSpecifier<unsigned int> {
  static constexpr const char* value = "%u";
};
template <>
struct ScanfSpecifier<long long int> {
  static constexpr const char* value = "%lld";
};
template <typename T>
int RD(T& arg) {
  return std::scanf(ScanfSpecifier<T>::value, &arg);
}
template <int S>
int RD(char (&arg)[S]) {
  return std::scanf("%s", arg);
}
int RD(char* arg) { return std::scanf("%s", arg); }
template <>
int RD<char>(char& arg) {
  return std::scanf(" %c", &arg);
}
template <typename T, typename... Args>
int RD(T& arg1, Args&... args) {
  return RD(arg1) + RD(args...);
}
template <typename T>
T RD() {
  T ret;
  RD(ret);
  return ret;
}
template <typename It>
void RDV(It begin, It end) {
  while (begin != end) RD(*begin++);
}
template <typename C>
void RDV(C& c) {
  RDV(std::begin(c), std::end(c));
}
template <typename T>
void WT(T arg) {
  std::printf(ScanfSpecifier<T>::value, arg);
}
template <typename T, typename U>
void WT(std::pair<T, U> arg) {
  std::printf("(");
  WT(arg.first);
  std::printf(", ");
  WT(arg.second);
  std::printf(")");
}
template <typename... Args>
void WT(Args... args) {
  int alc = 0;
  int dummy[] = {((alc++ ? std::printf(" ") : 0), WT(args), 0)...};
}
template <typename... Args>
void WTL(Args... args) {
  WT(args...);
  std::printf("\n");
}
template <typename It>
void WTV(It begin, It end) {
  int alc = 0;
  while (begin != end) (alc++ ? std::printf(" ") : 0), WT(*begin++);
}
template <typename C>
void WTV(const C& c) {
  WTV(std::begin(c), std::end(c));
}
template <typename It>
void WTVL(It begin, It end) {
  WTV(begin, end);
  std::printf("\n");
}
template <typename C>
void WTVL(const C& c) {
  WTVL(std::begin(c), std::end(c));
}
template <typename... Datas>
using UF = XX::UnionFind<Datas...>;
template <typename T>
T& UMAX(T& x, T y) {
  return XX::UP<std::greater>(x, y);
}
template <typename T>
T& UMIN(T& x, T y) {
  return XX::UP<std::less>(x, y);
}
using XX::UP;
using RG = XX::Range;
using XX::MAKEV;
using XX::Mapper;
using namespace std;
struct Data {
  long long w, b;
  void operator+=(const Data& rhs) {
    w += rhs.w;
    b += rhs.b;
  }
};
long long ww[1009];
long long bb[1009];
vector<int> sub[1009];
int main() {
  int N, M, W;
  RD(N, M, W);
  auto uf = UF<Data>(N);
  for (int i : RG(N)) {
    RD(ww[i]);
    uf[i].w = ww[i];
  }
  for (int i : RG(N)) {
    RD(bb[i]);
    uf[i].b = bb[i];
  }
  while (M--) {
    int x, y;
    RD(x, y);
    uf(x - 1, y - 1);
  }
  vector<bool> pass(N);
  vector<pair<int, pair<long long, long long>>> cad;
  for (int i : RG(N)) sub[uf(i)].push_back(i);
  for (int i : RG(N))
    if (!pass[uf(i)]) {
      pass[uf(i)] = true;
      cad.push_back({uf(i), {uf[i].w, uf[i].b}});
    }
  long long dp[1009] = {};
  dp[0] = 1;
  for (auto c : cad) {
    long long buf[1009];
    memcpy(buf, dp, sizeof(buf));
    for (int j = 0; j <= W - c.second.first; j++)
      if (buf[j]) {
        long long res = buf[j] + c.second.second;
        if (!dp[j + c.second.first] || dp[j + c.second.first] < res)
          dp[j + c.second.first] = res;
      }
    for (int k : sub[c.first])
      for (int j = 0; j <= W - ww[k]; j++)
        if (buf[j]) {
          long long res = buf[j] + bb[k];
          if (!dp[j + ww[k]] || dp[j + ww[k]] < res) dp[j + ww[k]] = res;
        }
  }
  long long ans = 0;
  for (int i : RG(W + 1)) UMAX(ans, dp[i]);
  WTL(ans - 1);
}
