#include <bits/stdc++.h>
using namespace std;
long long a[305], b[305], c[305], in[305], d[100005], mod = 1e9 + 7, n, t;
vector<int> edge[305];
void tp() {
  queue<int> q;
  for (int i = 1; i <= n; i++) {
    if (!in[i]) q.push(i);
  }
  int num = 0;
  while (q.size()) {
    int x = q.front();
    q.pop();
    num++;
    for (auto v : edge[x]) {
      in[v]--;
      t -= a[x];
      a[v] += a[x];
      if (in[v] == 0) q.push(v);
    }
  }
  if (num != n) {
    cout << 0 << endl;
    exit(0);
  }
}
int main() {
  long long q;
  cin >> n >> q >> t;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (long long i = 1; i <= q; i++) {
    cin >> b[i] >> c[i];
    edge[b[i]].push_back(c[i]);
    in[c[i]]++;
  }
  tp();
  d[0] = 1;
  if (t < 0) {
    cout << 0 << endl;
    return 0;
  }
  for (int i = 1; i <= n; i++) {
    for (int j = a[i]; j <= t; j++) {
      d[j] += d[j - a[i]];
      d[j] %= mod;
    }
  }
  cout << d[t] << endl;
}
