#include <bits/stdc++.h>
using namespace std;
const double PI = 3.1415926535;
const int MAXT = 100500, MAXN = 303, MOD = 1000000007;
bool root[MAXN], used[MAXN], leave[MAXN];
int ans[MAXT], n, t, q, p[MAXN], ch[MAXN], a[MAXN], b, c, cnt;
long long start_sum;
int main() {
  cin >> n >> q >> t;
  for (int i = 1; i <= n; ++i) cin >> a[i], root[i] = true, leave[i] = true;
  for (int i = 0; i < q; ++i) {
    cin >> b >> c;
    p[b] = c;
    ch[c] = b;
    root[b] = false;
    leave[c] = false;
  }
  for (int i = 1; i <= n; ++i) {
    if (root[i]) {
      for (int v = i, j = 0;; v = ch[v], ++j) {
        if (used[v]) {
          cout << 0;
          return 0;
        } else {
          used[v] = true;
          ++cnt;
          start_sum += j * a[v];
        }
        if (!ch[v]) break;
      }
    }
  }
  if (cnt < n || start_sum > t) {
    cout << 0;
    return 0;
  }
  for (int i = 1; i <= n; ++i)
    if (leave[i])
      for (int v = i;; v = p[v])
        if (p[v])
          a[p[v]] += a[v];
        else
          break;
  ans[start_sum] = 1;
  for (int i = 1; i <= n; ++i)
    for (long long j = start_sum; j + a[i] <= t; ++j)
      ans[j + a[i]] = (ans[j + a[i]] + ans[j]) % MOD;
  cout << ans[t];
  return 0;
}
