#include <bits/stdc++.h>
using namespace std;
const long long MAX_N = 35e1 + 35, MAX_T = 1e5 + 5, MOD = 1e9 + 7;
long long n, q, t;
long long Arr[MAX_N];
long long b[MAX_N];
long long c[MAX_N];
long long w[MAX_N];
bool mark[MAX_N];
long long nxt[MAX_N];
long long prv[MAX_N];
vector<long long> topo;
long long dp[MAX_T];
long long _sum(long long a, long long b) {
  long long c = a + b;
  if (MOD <= c) c -= MOD;
  return c;
}
bool dfs1(long long v) {
  mark[v] = true;
  if (!nxt[v]) return true;
  if (mark[nxt[v]]) return false;
  return dfs1(nxt[v]);
}
void dfs2(long long v, long long W) {
  W += Arr[v];
  w[v] = W;
  if (prv[v]) dfs2(prv[v], W);
}
void dfs3(long long v) {
  mark[v] = true;
  if (nxt[v] && !mark[nxt[v]]) dfs3(nxt[v]);
  topo.push_back(v);
}
int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  cin >> n >> q >> t;
  for (long long i = 1; i <= n; i++) cin >> Arr[i];
  for (long long i = 1; i <= q; i++) {
    cin >> c[i] >> b[i];
    nxt[b[i]] = c[i];
    prv[c[i]] = b[i];
  }
  for (long long i = 1; i <= n; i++)
    if (!mark[i] && !prv[i])
      if (!dfs1(i)) {
        cout << 0 << "\n";
        return 0;
      }
  for (long long i = 1; i <= n; i++)
    if (!mark[i]) {
      cout << 0 << "\n";
      return 0;
    }
  for (long long i = 1; i <= n; i++)
    if (!nxt[i]) dfs2(i, 0);
  for (long long i = 1; i <= n; i++)
    if (prv[i]) t -= w[i];
  if (t < 0) {
    cout << 0 << "\n";
    return 0;
  }
  memset(mark, 0, sizeof mark);
  for (long long i = 1; i <= n; i++)
    if (!mark[i]) dfs3(i);
  reverse(topo.begin(), topo.end());
  dp[0] = 1;
  for (long long i = 1; i <= n; i++) {
    long long v = topo[i - 1];
    for (long long j = w[v]; j <= t; j++) dp[j] = _sum(dp[j], dp[j - w[v]]);
  }
  cout << dp[t] << "\n";
  return 0;
}
