#include <bits/stdc++.h>
int n, m, t;
int num[310];
int in[310], to[310];
int no, total;
long long dp[100100];
int used[310];
int main() {
  memset(to, -1, sizeof(to));
  scanf("%d%d%d", &n, &m, &t);
  for (int i = 0; i < n; i++) scanf("%d", num + i);
  while (m--) {
    scanf("%d", &no);
    no--;
    scanf("%d", to + no);
    in[--to[no]] = 1;
  }
  for (int i = 0; i < n; i++)
    if (!in[i]) {
      for (int now = i;; now = to[now]) {
        if (!used[now])
          used[now] = 1;
        else {
          total = t + 1;
          break;
        }
        if (total > t) break;
        if (to[now] != -1) {
          num[to[now]] += num[now];
          total += num[now];
        } else
          break;
      }
    }
  for (int i = 0; i < n; i++)
    if (!used[i]) {
      total = -1;
      break;
    }
  if (total > t || total == -1) {
    puts("0");
    return 0;
  }
  dp[total] = 1;
  for (int i = 0; i < n; i++)
    for (int j = total; j + num[i] <= t; j++)
      dp[j + num[i]] = (dp[j + num[i]] + dp[j]) % 1000000007;
  printf("%I64d\n", dp[t]);
  return 0;
}
