#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC optimize("no-stack-protector,fast-math")
using namespace std;
const long long N = 1e6 + 100, OO = 1e16 + 7, T = 13, M = 1e9 + 7, P = 6151,
                SQ = 2, lg = 32;
long long a[N], en[N], nxt[N];
long long dp[N], n, q, t;
bool mark[N];
void Go(long long x, long long sum) {
  mark[x] = true;
  sum += a[x];
  if (nxt[x] == 0) {
    for (long long i = sum; i <= t; i++) dp[i] = (dp[i] + dp[i - sum]) % M;
    return;
  }
  for (long long i = t; i >= 0; i--) {
    if (i < sum)
      dp[i] = 0;
    else
      dp[i] = dp[i - sum];
  }
  for (long long i = sum; i <= t; i++) dp[i] = (dp[i] + dp[i - sum]) % M;
  Go(nxt[x], sum);
}
int32_t main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> n >> q >> t;
  dp[0] = 1;
  for (long long i = 1; i <= n; i++) cin >> a[i];
  for (long long i = 0; i < q; i++) {
    long long x, y;
    cin >> x >> y;
    nxt[x] = y;
    en[y]++;
  }
  for (long long i = 1; i <= n; i++)
    if (en[i] == 0) Go(i, 0);
  for (long long i = 1; i <= n; i++)
    if (!mark[i]) return cout << 0, 0;
  cout << dp[t] << endl;
  return 0;
}
