#include <bits/stdc++.h>
using namespace std;
long long dp[100010];
int a[310], in[310];
long long tmp[310];
struct edge {
  int to;
  int next;
} e[310];
int box[100010], cnt;
long long T;
void init() {
  memset(box, -1, sizeof(box));
  memset(in, 0, sizeof(in));
  memset(dp, 0, sizeof(dp));
  cnt = 0;
}
void add(int from, int to) {
  e[cnt].to = to;
  e[cnt].next = box[from];
  box[from] = cnt++;
}
long long dfs(int now) {
  tmp[now] = a[now];
  int t, v;
  for (t = box[now]; t + 1; t = e[t].next) {
    v = e[t].to;
    long long tt = dfs(v);
    tmp[now] += tt;
  }
  T -= tmp[now];
  return tmp[now];
}
bool iscircle(int n) {
  int qu[310], tmp[310];
  int i, sum = 0, top = 0;
  for (i = 1; i <= n; i++) {
    tmp[i] = in[i];
    if (tmp[i] == 0) qu[top++] = i;
  }
  for (i = 0; i < top; i++) {
    int now = qu[i], t, v;
    for (t = box[now]; t + 1; t = e[t].next) {
      v = e[t].to;
      tmp[v]--;
      if (!tmp[v]) qu[top++] = v;
    }
  }
  if (top < n) return true;
  return false;
}
int main() {
  int n, q, i, aa, b, j;
  scanf("%d%d%I64d", &n, &q, &T);
  for (i = 1; i <= n; i++) scanf("%d", &a[i]);
  init();
  for (i = 1; i <= q; i++) {
    scanf("%d%d", &aa, &b);
    in[aa]++;
    add(b, aa);
  }
  bool tru = iscircle(n);
  for (i = 1; i <= n; i++) {
    if (!in[i]) {
      dfs(i);
      T += tmp[i];
    }
  }
  if (tru || T < 0)
    printf("0\n");
  else {
    dp[0] = 1;
    for (i = 1; i <= n; i++) {
      for (j = tmp[i]; j <= T; j++)
        dp[j] = (dp[j] + dp[j - tmp[i]]) % 1000000007;
    }
    printf("%I64d\n", dp[T]);
  }
  return 0;
}
