#include <bits/stdc++.h>
using namespace std;
int n, m;
long long tot;
long long a[310], at[310];
int nxt[310], pre[310];
bool vis[310];
int tac = 0;
long long md = 1e9 + 7;
long long d[310][100010];
int main() {
  scanf("%d%d%I64d", &n, &m, &tot);
  for (int i = 0; i < n; i++) {
    scanf("%I64d", &at[i]);
    nxt[i] = pre[i] = -1;
  }
  for (int i = 0; i < m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    x--, y--;
    pre[y] = x, nxt[x] = y;
  }
  for (int i = 0; i < n; i++) {
    if (vis[i] || pre[i] != -1) continue;
    int t = i;
    vis[t] = 1;
    a[tac] = at[t];
    if (nxt[t] != -1) tot -= a[tac];
    tac++;
    while (nxt[t] != -1) {
      t = nxt[t];
      if (vis[t]) {
        printf("0");
        return 0;
      }
      vis[t] = 1;
      a[tac] = at[t] + a[tac - 1];
      if (nxt[t] != -1) tot -= a[tac];
      tac++;
    }
  }
  if (tot < 0 || tac != n) {
    printf("0");
    return 0;
  }
  d[0][0] = 1;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= tot; j++) d[i + 1][j] = d[i][j];
    for (int j = 0; j <= tot - a[i]; j++)
      d[i + 1][j + a[i]] = (d[i + 1][j + a[i]] + d[i + 1][j]) % md;
  }
  printf("%I64d", d[n][tot]);
  return 0;
}
