#include <bits/stdc++.h>
using namespace std;
const int INFTY = 1 << 29;
const double EPS = 1e-9;
template <typename T1, typename T2>
ostream& operator<<(ostream& os, const pair<T1, T2>& p) {
  return os << '(' << p.first << ',' << p.second << ')';
}
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& a) {
  os << '[';
  for (int i = int(0); i < int(a.size()); i++) os << (i ? " " : "") << a[i];
  return os << ']';
}
void dfs(const vector<int>& g, int i, vector<int>& must, vector<int>& sum) {
  if (g[i] != -1) {
    must[g[i]] = must[i] + 1;
    dfs(g, g[i], must, sum);
    sum[i] += sum[g[i]];
  }
}
int main() {
  const int MOD = 1e9 + 7;
  for (int n, q, t; cin >> n >> q >> t;) {
    vector<int> a(n), b(q), c(q);
    for (int i = int(0); i < int(n); i++) cin >> a[i];
    for (int i = int(0); i < int(q); i++) {
      cin >> b[i] >> c[i];
      b[i]--, c[i]--;
    }
    vector<int> g(n, -1);
    for (int i = int(0); i < int(q); i++) g[c[i]] = b[i];
    bool cycle = false;
    for (int i = int(0); i < int(n); i++)
      for (int j = g[i]; j != -1; j = g[j])
        if (j == i) {
          cycle = true;
          break;
        }
    if (cycle) {
      cout << 0 << endl;
      continue;
    }
    vector<int> in(n), out(n);
    for (int i = int(0); i < int(q); i++) in[b[i]]++, out[c[i]]++;
    vector<int> must(n), sum = a;
    for (int i = int(0); i < int(n); i++)
      if (in[i] == 0) dfs(g, i, must, sum);
    vector<int> dp(t + 1);
    if (inner_product(begin(must), end(must), a.begin(), 0ll) <= t)
      dp[inner_product(begin(must), end(must), a.begin(), 0ll)] = 1;
    for (int i = int(0); i < int(n); i++)
      for (int j = int(sum[i]); j < int(t + 1); j++) {
        dp[j] += dp[j - sum[i]];
        dp[j] %= MOD;
      }
    cout << dp[t] << endl;
  }
  return 0;
}
