#include <bits/stdc++.h>
using namespace std;
void io_in_data() {
  freopen("data.in", "r", stdin);
  freopen("data.out", "w", stdout);
}
const int MAXN = 307;
const int MOD = 1000000000 + 7;
int bf[MAXN], nxt[MAXN], vis[MAXN];
int a[MAXN], a0[MAXN], a1[MAXN];
int dp[100007];
int N;
int dfs(int u) {
  if (vis[u]) return -1;
  vis[u] = 1;
  a0[u] = 0;
  a1[u] = a[u];
  int ret = 1;
  int v = nxt[u];
  if (v != -1) {
    ret += dfs(v);
    if (ret == 0) return -1;
    a0[u] += (a0[v] + a1[v]) % MOD;
    a0[u] %= MOD;
    a1[u] += a1[v];
    a1[u] %= MOD;
  }
  return ret;
}
int main() {
  int n, q, T;
  while (~scanf("%d%d%d", &n, &q, &T)) {
    N = n;
    memset(bf, 1, sizeof(bf));
    memset(nxt, -1, sizeof(nxt));
    int i, j, u, v;
    for (i = 1; i <= n; i++) scanf("%d", a + i);
    for (i = 1; i <= q; i++) {
      scanf("%d%d", &u, &v);
      nxt[v] = u;
      bf[u] = 0;
    }
    int tot = 0;
    memset(vis, 0, sizeof(vis));
    for (i = 1; i <= n; i++)
      if (bf[i]) {
        tot += dfs(i);
        T -= a0[i];
      }
    if (T < 0 || tot != n) {
      puts("0");
      continue;
    }
    memset(dp, 0, sizeof(dp));
    dp[0] = 1;
    for (i = 1; i <= n; i++) {
      int v = a1[i];
      while (v <= T) {
        for (j = T; j >= v; j--) dp[j] = (dp[j] + dp[j - v]) % MOD;
        v *= 2;
      }
    }
    printf("%d\n", dp[T]);
  }
  return 0;
}
