#include <bits/stdc++.h>
using namespace std;
int n, a[310], nxt[310], v[310], cnt, dp[100010];
long long int t;
bool hd[310];
void calc(int idx, int h) {
  cnt++;
  t -= (a[idx] * h);
  if (nxt[idx]) calc(nxt[idx], h + 1);
  v[idx] = a[idx] + v[nxt[idx]];
}
int main() {
  ios_base::sync_with_stdio(0);
  int q, i, j, b, c;
  bool ok = 1;
  cin >> n >> q >> t;
  for (i = 1; i <= n; i++) {
    cin >> a[i];
    nxt[i] = v[i] = hd[i] = 0;
  }
  while (q--) {
    cin >> b >> c;
    nxt[c] = b;
    hd[b] = 1;
  }
  for (cnt = 0, i = 1; i <= n && ok; i++)
    if (hd[i] == 0) calc(i, 0);
  if (cnt != n || t < 0)
    cout << "0\n";
  else {
    fill(dp, dp + t + 1, 0);
    for (dp[0] = i = 1; i <= n; i++) {
      for (j = v[i]; j <= t; j++) {
        dp[j] += dp[j - v[i]];
        if (dp[j] >= 1000000007) dp[j] -= 1000000007;
      }
    }
    cout << dp[t] << "\n";
  }
}
