#include <bits/stdc++.h>
const int maxn = 100000 + 2;
const int Mod = 1000000007;
int dp[2][maxn];
int a[310], fa[310], nt[310], qu[310], sum[310];
void ck(int &x, int y) {
  x += y;
  if (x >= Mod) x -= Mod;
}
int main() {
  int n, q, t;
  int u, v;
  while (scanf("%d%d%d", &n, &q, &t) == 3) {
    for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
    memset(nt, -1, sizeof(nt));
    memset(fa, -1, sizeof(fa));
    while (q--) {
      scanf("%d%d", &u, &v);
      fa[v] = u;
      nt[u] = v;
    }
    memset(sum, 0, sizeof(sum));
    int st = 0, ed = 0;
    for (int i = 1; i <= n; i++)
      if (fa[i] == -1) {
        qu[++ed] = i;
      }
    while (st < ed) {
      int u = qu[++st];
      if (fa[u] != -1) ck(sum[u], sum[fa[u]]);
      sum[u] += a[u];
      if (nt[u] != -1) qu[++ed] = nt[u];
    }
    if (ed != n)
      puts("0");
    else {
      memset(dp, 0, sizeof(dp));
      dp[0][0] = 1;
      for (int i = 1; i <= n; i++) {
        memset(dp[1], 0, sizeof(dp[1]));
        for (int j = 0; j <= t; j++) {
          if (nt[i] == -1) dp[1][j] = dp[0][j];
          if (j >= sum[i]) {
            if (nt[i] == -1)
              ck(dp[1][j], dp[1][j - sum[i]]);
            else
              ck(dp[1][j], dp[1][j - sum[i]] + dp[0][j - sum[i]]);
          }
        }
        for (int j = 0; j <= t; j++) dp[0][j] = dp[1][j];
      }
      printf("%d\n", dp[0][t]);
    }
  }
  return 0;
}
