#include <bits/stdc++.h>
using namespace std;
template <typename T1, typename T2>
inline T1 max(T1 a, T2 b) {
  return a < b ? b : a;
}
template <typename T1, typename T2>
inline T1 min(T1 a, T2 b) {
  return a < b ? a : b;
}
const char lf = '\n';
namespace ae86 {
const int bufl = 1 << 15;
char buf[bufl], *s = buf, *t = buf;
inline int fetch() {
  if (s == t) {
    t = (s = buf) + fread(buf, 1, bufl, stdin);
    if (s == t) return EOF;
  }
  return *s++;
}
inline int ty() {
  int a = 0;
  int b = 1, c = fetch();
  while (!isdigit(c)) b ^= c == '-', c = fetch();
  while (isdigit(c)) a = a * 10 + c - 48, c = fetch();
  return b ? a : -a;
}
}  // namespace ae86
using ae86::ty;
const int _ = 307, __ = 100007, mo = 1000000007;
template <typename T1, typename T2>
inline T1 ad(T1 &a, T2 b) {
  return a = a + b >= mo ? a + b - mo : a + b;
}
template <typename T1, typename T2>
inline T1 dl(T1 &a, T2 b) {
  return a = a >= b ? a - b : a - b + mo;
}
inline void failure() {
  cout << 0 << lf;
  exit(0);
}
int n, m, tar, fa[_] = {0}, ed[_] = {0}, val[_] = {0};
int vis[_] = {0};
void dfs(int x, int dep) {
  vis[x] = 1, tar -= dep * val[x];
  if (tar < 0) failure();
  if (fa[x]) dfs(fa[x], dep + 1), val[x] += val[fa[x]];
}
long long f[__] = {0};
int main() {
  ios::sync_with_stdio(0), cout.tie(nullptr);
  n = ty(), m = ty(), tar = ty();
  for (int i = 1; i <= n; i++) val[i] = ty();
  for (int i = 1, a, b; i <= m; i++) a = ty(), b = ty(), ed[a] = 1, fa[b] = a;
  for (int i = 1; i <= n; i++)
    if (!ed[i]) dfs(i, 0);
  for (int i = 1; i <= n; i++)
    if (ed[i] && !vis[i]) failure();
  f[0] = 1;
  for (int i = 1; i <= n; i++)
    for (int j = val[i]; j <= tar; j++) ad(f[j], f[j - val[i]]);
  cout << f[tar] << lf;
  return 0;
}
