#include <bits/stdc++.h>
using namespace std;
const int MOD = (int)(1e9 + 7);
int a[305], val[305];
int cnt[100000 + 5];
int nextnode[305];
int len[305];
pair<int, int> edges[305];
int Nedge;
int main() {
  int n, q, t;
  cin >> n >> q >> t;
  for (int i = 0; i < n; ++i) cin >> a[i];
  for (int i = 0; i < q; ++i) {
    int b, c;
    cin >> b >> c;
    --b;
    --c;
    edges[Nedge++] = make_pair(b, c);
  }
  for (int i = 0; i < n; ++i) {
    nextnode[i] = i;
  }
  bool update = true;
  bool hascycle = false;
  while (update) {
    update = false;
    for (int i = 0; i < Nedge; ++i) {
      int b, c;
      b = edges[i].first;
      c = edges[i].second;
      nextnode[c] = b;
      if (len[b] < len[c] + 1) {
        update = true;
        len[b] = len[c] + 1;
        if (len[b] >= n) {
          hascycle = true;
          break;
        }
      }
    }
    if (hascycle) {
      cout << 0 << endl;
      return 0;
    }
  }
  for (int i = 0; i < n; ++i) {
    int k = i;
    while (k != nextnode[k]) {
      val[i] += a[k];
      k = nextnode[k];
    }
    val[i] += a[k];
  }
  for (int i = 0; i < n; ++i) {
    if (len[i] > 0) t -= val[i];
    if (t < 0) break;
  }
  if (t < 0) {
    cout << 0 << endl;
    return 0;
  }
  cnt[0] = 1;
  for (int x = 1; x <= n; ++x) {
    for (int v = 0; v <= t; ++v) {
      int prev = v - val[x - 1];
      if (prev >= 0) {
        cnt[v] += cnt[prev];
        if (cnt[v] >= MOD) cnt[v] -= MOD;
      }
    }
  }
  cout << cnt[t] << endl;
}
