#include <bits/stdc++.h>
using namespace std;
int n, q, t;
int a[330], dp[100007];
int vv[330], nxt[330], h[330], e;
int vis[330], b[330];
bool bfs(int u) {
  if (!nxt[u] || vis[u]) return 1;
  vis[u] = 1;
  int v;
  while (nxt[u]) {
    v = nxt[u];
    if (vis[v]) return 0;
    vis[v] = 1;
    a[v] += a[u];
    if (a[v] > 100000) a[v] = 100001;
    t -= a[u];
    u = v;
  }
  return 1;
}
int main() {
  int u, v, k = 0;
  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);
    nxt[u] = v;
    b[v] = 1;
  }
  for (int i = 1; i <= n; ++i) {
    if (!b[i]) {
      if (!bfs(i)) {
        k = 0;
        break;
      }
      k = 1;
    }
  }
  for (int i = 1; i <= n; ++i)
    if (nxt[i] && !vis[i]) {
      k = 0;
      break;
    }
  if (k == 0 || t < 0) {
    puts("0");
    return 0;
  }
  dp[0] = 1;
  for (int i = 1; i <= n; ++i)
    for (int j = 0; j + a[i] <= t; ++j) {
      dp[j + a[i]] += dp[j];
      if (dp[j + a[i]] >= 1000000007) dp[j + a[i]] -= 1000000007;
    }
  int ans = dp[t];
  printf("%d\n", ans);
}
