#include <bits/stdc++.h>
using namespace std;
int const N = 300 + 20, T = 1e5 + 20, MOD = 1e9 + 7;
int n, q, t, a[N], cnt[N], h[N], dp[T];
bool vis[N];
vector<int> adj[N];
int dfs(int v, int par = -1) {
  vis[v] = 1;
  if (par != -1) h[v] = h[par] + 1;
  t -= (1LL * h[v] * a[v]) % MOD;
  if (t < 0) {
    cout << 0 << '\n';
    exit(0);
  }
  if (adj[v].size()) a[v] += dfs(adj[v][0], v);
  return a[v];
}
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> q >> t;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < q; i++) {
    int x, y;
    cin >> x >> y;
    x--, y--;
    adj[y].push_back(x);
    cnt[x]++;
  }
  for (int i = 0; i < n; i++)
    if (!cnt[i]) dfs(i);
  for (int i = 0; i < n; i++)
    if (!vis[i]) return cout << 0 << '\n', 0;
  for (int i = 0; i < n; i++) cerr << a[i] << ' ';
  cerr << endl;
  dp[0] = 1;
  for (int i = 0; i < n; i++)
    for (int c = a[i]; c <= t; c++) {
      dp[c] += dp[c - a[i]];
      if (dp[c] >= MOD) dp[c] -= MOD;
    }
  return cout << dp[t] << '\n', 0;
}
