#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
const int MAXN = 305;
const int MAXT = 100005;
int a[MAXN], e[MAXN], d[MAXN];
long long dp[MAXT];
long long t, cnt;
void dfs(int u, int acc) {
  if (t < 0) {
    return;
  }
  ++cnt;
  a[u] += acc;
  if (e[u] != 0) {
    dfs(e[u], a[u]);
    t -= a[u];
    if (t < 0) {
      return;
    }
  }
}
int main() {
  int n, q;
  int u, v;
  scanf("%d%d%d", &n, &q, &t);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", a + i);
  }
  while (q--) {
    scanf("%d%d", &u, &v);
    e[u] = v;
    d[v] = 1;
  }
  for (int i = 1; i <= n && t >= 0; ++i) {
    if (d[i] == 0) {
      dfs(i, 0);
    }
  }
  if (t < 0 || cnt < n) {
    printf("0\n");
    return 0;
  }
  dp[0] = 1;
  for (int i = 1; i <= n; ++i) {
    for (int j = a[i]; j <= t; ++j) {
      dp[j] = (dp[j] + dp[j - a[i]]) % MOD;
    }
  }
  printf("%d\n", dp[t]);
  return 0;
}
