#include <bits/stdc++.h>
using namespace std;
int n, q, t, a[305];
vector<int> G[305];
int indeg[305];
queue<int> dl;
inline bool topo() {
  for (int i = 1; i <= n; i++)
    if (!indeg[i]) dl.push(i);
  int idx = 0;
  while (!dl.empty()) {
    int u = dl.front();
    dl.pop();
    idx++;
    if (G[u].size()) t -= a[u];
    if (t < 0) return 0;
    for (int i = 0; i < G[u].size(); i++) {
      int v = G[u][i];
      a[v] += a[u];
      if (!--indeg[v]) dl.push(v);
    }
  }
  if (idx < n) return 0;
  return 1;
}
long long dp[100005];
int main() {
  scanf("%d%d%d", &n, &q, &t);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  memset(indeg, 0, sizeof(indeg));
  while (q--) {
    int b, c;
    scanf("%d%d", &b, &c);
    G[b].push_back(c);
    indeg[c]++;
  }
  if (topo()) {
    memset(dp, 0, sizeof(dp));
    dp[0] = 1;
    for (int i = 1; i <= n; i++) {
      for (int v = a[i]; v <= t; v++)
        dp[v] = (dp[v] + dp[v - a[i]]) % 1000000007;
    }
    printf("%lld\n", dp[t]);
  } else {
    printf("0\n");
    return 0;
  }
  return 0;
}
