#include <bits/stdc++.h>
using namespace std;
long long arr[350];
long long done[350];
long long adj[350];
long long adji[350];
long long rooto[350];
long long n, q, t;
vector<vector<long long> > arrs;
int getInt() {
  long long gg = -1;
  for (__typeof(n) i = 0; i < n; i++) {
    if (done[i] == 0) {
      gg = i;
      break;
    }
    if (i == n - 1) return -1;
  }
  vector<long long> ansb;
  vector<long long> ansa;
  ansa.push_back(gg);
  done[gg] = 1;
  long long ggg = gg;
  while (adj[gg] != -1) {
    gg = adj[gg];
    if (done[gg]) return -2;
    ansa.push_back(gg);
    done[gg] = 1;
  }
  gg = ggg;
  while (adji[gg] != -1) {
    gg = adji[gg];
    if (done[gg]) return -2;
    ansb.push_back(gg);
    done[gg] = 1;
  }
  vector<long long> ans;
  reverse(ansb.begin(), ansb.end());
  for (__typeof(ansb.size()) i = 0; i < ansb.size(); i++) {
    ans.push_back(ansb[i]);
  }
  for (__typeof(ansa.size()) i = 0; i < ansa.size(); i++) {
    ans.push_back(ansa[i]);
  }
  arrs.push_back(ans);
  return 1;
}
vector<long long> ttt;
long long subsetsum() {
  vector<long long> sumdp(100005);
  long long nn = ttt.size();
  for (__typeof(100005) i = 0; i < 100005; i++) {
    sumdp[i] = 0;
  }
  sumdp[0] = 1;
  for (__typeof(nn) i = 0; i < nn; i++) {
    for (__typeof(100005) j = 0; j < 100005; j++) {
      if (j >= ttt[i]) {
        sumdp[j] = (sumdp[j] + sumdp[j - ttt[i]]) % 1000000007;
      }
    }
  }
  return sumdp[t];
}
int main() {
  memset(done, 0, sizeof(done));
  memset(adj, -1, sizeof(adj));
  memset(adji, -1, sizeof(adji));
  cin >> n >> q >> t;
  for (__typeof(n) i = 0; i < n; i++) {
    cin >> arr[i];
  }
  for (__typeof(q) i = 0; i < q; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    adj[a] = b;
    adji[b] = a;
  }
  while (true) {
    int gola = getInt();
    if (gola == -1) break;
    if (gola == -2) {
      cout << 0 << endl;
      return 0;
    }
  }
  vector<long long> tt;
  for (__typeof(arrs.size()) i = 0; i < arrs.size(); i++) {
    long long sum = 0;
    for (__typeof(arrs[i].size()) j = 0; j < arrs[i].size(); j++) {
      sum += arr[arrs[i][j]];
      tt.push_back(sum);
      if (j < arrs[i].size() - 1) t -= sum;
    }
  }
  sort(tt.begin(), tt.end());
  ttt = tt;
  if (t < 0) {
    cout << 0 << endl;
    return 0;
  }
  cout << subsetsum() << endl;
  return 0;
}
