#include <bits/stdc++.h>
using namespace std;
using namespace std;
int tol, dp[100005], a[305], to[305], in[305];
bool vis[305][305];
bool circle(int n) {
  int i, j, k;
  for (k = 1; k <= n; k++)
    for (i = 1; i <= n; i++)
      for (j = 1; j <= n; j++) vis[i][j] |= (vis[i][k] && vis[k][j]);
  for (i = 1; i <= n; i++)
    for (j = 1; j <= n; j++)
      if (vis[i][j] && vis[j][i]) return true;
  return false;
}
int DP(int n) {
  int i, j;
  dp[0] = 1;
  for (i = 1; i <= n; i++) {
    for (j = a[i]; j <= tol; j++) dp[j] = (dp[j] + dp[j - a[i]]) % 1000000007;
  }
  return dp[tol];
}
void dfs(int n) {
  if (!to[n]) return;
  a[to[n]] += a[n];
  dfs(to[n]);
  tol -= a[n];
  if (tol < 0) tol = -1;
}
int main() {
  int m, n, i, j, k;
  cin >> n >> m >> tol;
  for (i = 1; i <= n; i++) cin >> a[i];
  for (i = 1; i <= m; i++) {
    int first, second;
    cin >> first >> second;
    in[second] = 1;
    to[first] = second;
    vis[first][second] = 1;
  }
  for (i = 1; i <= n; i++)
    if (!in[i]) dfs(i);
  if (circle(n) || tol < 0) return puts("0");
  cout << DP(n) << endl;
}
