#include <bits/stdc++.h>
using namespace std;
int n, q, t, v[305], g[305][305], s[305], p, l[305], ans[100005], tot;
long long add;
bool f[305];
void dfs(int x) {
  if (!x) return;
  tot++;
  g[p][l[p]++] = x;
  dfs(s[x]);
}
int main() {
  scanf("%d %d %d", &n, &q, &t);
  for (int i = (1); i <= (n); i++) scanf("%d", &v[i]);
  while (q--) {
    int a, b;
    scanf("%d %d", &a, &b);
    f[b] = 1;
    s[a] = b;
  }
  for (int i = (1); i <= (n); i++)
    if (!f[i]) {
      dfs(i);
      p++;
    }
  if (tot < n) {
    puts("0");
    return 0;
  }
  ans[0] = 1;
  for (int i = (0); i < (p); i++)
    for (int j = (1); j < (l[i]); j++) v[g[i][j]] += v[g[i][j - 1]];
  for (int i = (0); i < (p); i++)
    for (int j = (0); j < (l[i] - 1); j++) add += v[g[i][j]];
  for (int i = (0); i < (p); i++)
    for (int j = (0); j < (l[i]); j++) {
      int V = v[g[i][j]];
      for (int i = (V); i <= (t); i++)
        ans[i] = (ans[i] + ans[i - V]) % 1000000007;
    }
  printf("%d\n", add > t ? 0 : ans[t - add]);
  scanf("\n");
}
