#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
const int inf = 1e9;
const int MOD = 1e9 + 7;
long long g[maxn];
long long a[maxn], d[maxn], dp[maxn];
long long n, q, t;
bool vis[maxn], en[maxn];
void dfs(int v) {
  vis[v] = 1;
  if (g[v]) {
    if (!vis[g[v]])
      dfs(g[v]);
    else if (!en[g[v]]) {
      cout << 0 << '\n';
      exit(0);
    }
  } else if (g[v] == 0) {
    en[v] = 1;
    return;
  }
  en[v] = 1;
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  cin >> n >> q >> t;
  for (int i = 1; i <= n; i++) cin >> a[i];
  while (q--) {
    int u, v;
    cin >> u >> v;
    d[v] = d[v] + 1;
    g[u] = v;
  }
  for (int i = 1; i <= n; i++)
    if (!vis[i]) dfs(i);
  for (int i = 1; i <= n; i++) {
    if (d[i]) continue;
    long long ind = i;
    long long sum = 0;
    while (ind) {
      sum = sum + a[ind];
      a[ind] = sum;
      if (g[ind]) t = t - a[ind];
      ind = g[ind];
    }
  }
  if (t < 0) {
    cout << 0 << '\n';
    return 0;
  }
  dp[0] = 1;
  for (int i = 1; i <= n; i++)
    for (long long j = a[i]; j <= t; j++) dp[j] = (dp[j] + dp[j - a[i]]) % MOD;
  cout << dp[t] << '\n';
  return 0;
}
