#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
map<int, int> m;
long long val[100001];
char chk[301];
int n, tt, q, x, y, i, j, l, f, ct, sum;
long long s[301], a[301], t;
int parent[301];
int find_set(int v) {
  if (parent[v] == v)
    return v;
  else
    find_set(parent[v]);
}
int main() {
  cin >> n >> q >> t;
  for (i = 1; i <= n; i++) cin >> a[i];
  for (i = 1; i <= n; i++) s[i] = a[i], parent[i] = i;
  for (i = 0; i < q; i++) {
    cin >> x >> y;
    m[x] = y;
  }
  for (i = 1; i <= n; i++)
    if (m[i]) {
      if (find_set(i) == find_set(m[i])) {
        f = 1;
        break;
      }
      parent[i] = m[i];
      int pos = m[i], pre = i;
      while (1) {
        s[pos] = s[pre] + a[pos];
        if (pos == parent[pos]) break;
        pre = pos;
        pos = parent[pos];
      }
    }
  if (f)
    cout << 0 << endl;
  else {
    for (i = 1; i <= n; i++) t -= s[i] - a[i];
    if (t < 0)
      cout << 0 << endl;
    else {
      val[0] = 1;
      for (i = 1; i <= n; i++) {
        for (j = 0; j <= t - s[i]; j++)
          if (val[j] && j + s[i] <= t) {
            val[j + s[i]] += val[j];
            val[j + s[i]] %= mod;
          }
      }
      cout << val[t] << endl;
    }
  }
  return 0;
}
