#include <bits/stdc++.h>
using namespace std;
int n, m, S, Bad, dp[305][100005];
int val[305], in[305], v[305], nxt[305], l, viz[305];
inline void Solve(int nod) {
  v[++l] = val[nod];
  viz[nod] = 1;
  int x = nod, sum = val[nod];
  long long Sum = 0;
  Sum = v[l];
  while (nxt[x]) {
    sum += val[nxt[x]];
    v[++l] = sum;
    Sum += v[l];
    x = nxt[x];
    viz[x] = 1;
  }
  Sum -= v[l];
  if (S < Sum)
    Bad = 1;
  else
    S -= Sum;
}
inline void Verif(int nod) {
  int x = nod;
  viz[x] = 1;
  while (nxt[x]) {
    if (nxt[x] == nod) {
      Bad = 1;
      return;
    }
    x = nxt[x];
    viz[x] = 1;
  }
}
int main() {
  int i, j, x, y;
  cin.sync_with_stdio(0);
  cin >> n >> m >> S;
  for (i = 1; i <= n; ++i) cin >> val[i];
  while (m--) {
    cin >> x >> y;
    nxt[x] = y;
    ++in[y];
  }
  for (i = 1; i <= n; ++i)
    if (!in[i]) Solve(i);
  for (i = 1; i <= n; ++i)
    if (!viz[i]) Verif(i);
  if (Bad) {
    cout << '0';
    return 0;
  }
  dp[0][0] = 1;
  for (i = 1; i <= l; ++i)
    for (j = 0; j <= S; ++j) {
      dp[i][j] = dp[i - 1][j];
      if (v[i] <= j) dp[i][j] += dp[i][j - v[i]];
      if (dp[i][j] >= 1000000007) dp[i][j] -= 1000000007;
    }
  cout << dp[l][S];
  return 0;
}
