#include <bits/stdc++.h>
using namespace std;
const int maxn = 100005, mod = 1e9 + 7;
inline int gi() {
  char c = getchar();
  while (c < '0' || c > '9') c = getchar();
  int sum = 0;
  while ('0' <= c && c <= '9') sum = sum * 10 + c - 48, c = getchar();
  return sum;
}
int n, m, t, a[maxn], nxt[maxn], p[maxn], f[maxn], vis[maxn], deg[maxn], cnt;
int main() {
  n = gi();
  m = gi();
  t = gi();
  for (int i = 1; i <= n; ++i) a[i] = gi();
  for (int x, y, i = 1; i <= m; ++i) x = gi(), y = gi(), nxt[x] = y, ++deg[y];
  int _cnt = 0;
  for (int i = 1; i <= n; ++i)
    if (!deg[i]) {
      int x = i;
      cnt = 0;
      while (x && nxt[x] && nxt[x] != x) p[++cnt] = x, vis[x] = 1, x = nxt[x];
      p[++cnt] = x;
      vis[x] = 1;
      _cnt += cnt;
      for (int i = 1; i <= cnt; ++i) {
        if (t >= a[p[i]] * (cnt - i))
          t -= a[p[i]] * (cnt - i);
        else
          return puts("0"), 0;
        a[p[i]] += a[p[i - 1]];
      }
    }
  if (_cnt != n || t < 0) return puts("0"), 0;
  f[0] = 1;
  for (int i = 1; i <= n; ++i)
    for (int j = a[i]; j <= t; ++j) f[j] = (f[j] + f[j - a[i]]) % mod;
  printf("%d\n", f[t]);
  return 0;
}
