#include <bits/stdc++.h>
using namespace std;
const long long Mod = 1e9 + 7;
const int Maxt = 1e5 + 10, Maxn = 300 + 10;
int n, q, t, nxt[Maxn], prv[Maxn];
bool mark[Maxn];
long long dp[Maxn][Maxt], sum, a[Maxn];
int main() {
  cin >> n >> q >> t;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 0, b, c; i < q; i++) {
    cin >> b >> c;
    nxt[c] = b;
    prv[b] = c;
  }
  for (int i = 1; i <= n; i++) {
    if (nxt[i] == 0) {
      int h = i, ps = 0;
      while (h != 0) {
        ps += a[h], a[h] = ps;
        mark[h] = true;
        h = prv[h];
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    if (!mark[i]) return cout << 0, 0;
    if (prv[i] != 0) sum += a[i];
  }
  if (sum > t) return cout << 0, 0;
  dp[0][sum] = 1;
  for (int j = 1; j <= n; j++) {
    for (int i = sum; i <= t; i++) {
      dp[j][i] = dp[j - 1][i];
      if (i - a[j] >= sum) dp[j][i] = (dp[j][i] + dp[j][i - a[j]]) % Mod;
    }
  }
  cout << dp[n][t];
}
