#include <bits/stdc++.h>
using namespace std;
int n, q, t;
int a[100005], e[305], deg[305];
int v[305], ok = 1;
int dp[100005];
int mod = 1000000007;
void doit(int at) {
  if (at == -1) return;
  v[at] = 1;
  if (v[e[at]] == 1) {
    ok = 0;
    return;
  }
  doit(e[at]);
}
int main() {
  scanf("%d%d%d", &n, &q, &t);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  memset(deg, 0, sizeof(deg));
  memset(e, -1, sizeof(e));
  for (int i = 0; i < q; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    x--;
    y--;
    e[x] = y;
    deg[y] = 1;
  }
  memset(v, 0, sizeof(v));
  for (int i = 0; i < n; i++)
    if (deg[i] == 0) doit(i);
  for (int i = 0; i < n; i++)
    if (v[i] == 0) ok = 0;
  if (!ok) {
    puts("0");
    return 0;
  }
  int now = 0;
  memset(dp, 0, sizeof(dp));
  dp[0] = 1;
  for (int i = 0; i < n; i++) {
    if (deg[i] == 0) {
      int at = i;
      now = a[at];
      do {
        for (int j = now; j <= t; j++) {
          dp[j] += dp[j - now];
          dp[j] %= mod;
        }
        at = e[at];
        if (at != -1) {
          if (t >= 0) t -= now;
          now += a[at];
        }
      } while (at != -1);
    }
  }
  if (t < 0)
    printf("0\n");
  else
    printf("%d\n", dp[t]);
  return 0;
}
