#include <bits/stdc++.h>
long long mpow(long long a, long long n, long long mod) {
  long long ret = 1;
  long long b = a;
  while (n) {
    if (n & 1) ret = (ret * b) % mod;
    b = (b * b) % mod;
    n >>= 1;
  }
  return (long long)ret;
}
using namespace std;
int n, q, t;
int dp[(int)(3e2 + 25)][200005], a[(int)(3e2 + 25)], vis[(int)(3e2 + 25)],
    atleast[(int)(3e2 + 25)], in[(int)(3e2 + 25)], val[(int)(3e2 + 25)];
bool poss = 1;
vector<int> G[(int)(3e2 + 25)];
long long mod = 1e9 + 7;
int dfs(int x) {
  if (!poss) return -1;
  if (vis[x] == 1) {
    poss = 0;
    return -1;
  }
  vis[x] = 1;
  atleast[x] = 0;
  for (int i = 0; i < G[x].size(); i++) {
    int to = G[x][i];
    dfs(to);
    if (!poss) return -1;
    atleast[x] = max(atleast[x], atleast[to] + 1);
  }
  vis[x] = 2;
  return atleast[x];
}
void calc(int x, int p) {
  val[x] += p;
  if (val[x] == p + a[x]) p += a[x];
  for (int i = 0; i < G[x].size(); i++) calc(G[x][i], p);
}
void solve() {
  scanf("%d", &n);
  scanf("%d", &q);
  scanf("%d", &t);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  for (int i = 1; i <= q; i++) {
    int x, y;
    scanf("%d", &x);
    scanf("%d", &y);
    G[x].push_back(y);
    in[y] = 1;
  }
  for (int i = 1; i <= n; i++)
    if (!vis[i]) dfs(i);
  for (int i = 1; i <= n; i++)
    if (t >= 0) t -= atleast[i] * a[i];
  if (t < 0 || !poss) {
    printf("0");
    return;
  }
  for (int i = 1; i <= n; i++) val[i] = a[i];
  for (int i = 1; i <= n; i++)
    if (!in[i]) calc(i, 0);
  dp[0][0] = 1;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j <= t; j++) {
      dp[i][j] = dp[i - 1][j];
      if (j - val[i] >= 0) {
        dp[i][j] = (dp[i][j] + dp[i][j - val[i]]) % mod;
      }
    }
  }
  cout << dp[n][t];
}
int main() {
  int t = 1;
  for (int i = 1; i <= t; i++) {
    solve();
  }
  return 0;
}
