#include <bits/stdc++.h>
using namespace std;
int n, q, t;
int a[100005];
int p[100005];
bool head[100005];
long long dp[100005];
bool loop(int x) {
  int y = x;
  while (y) {
    if (!p[y]) break;
    y = p[y];
    if (y == x) return 1;
  }
  return 0;
}
void cnt_loop(int x) {
  int y = x;
  while (y) {
    int u = -1;
    for (int i = 1; i <= n; i++)
      if (p[i] == y) {
        u = i;
        break;
      }
    if (u == -1) break;
    a[u] += a[y];
    y = u;
  }
}
int main() {
  cin >> n >> q >> t;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= q; i++) {
    int x, y;
    cin >> x >> y;
    p[y] = x;
    head[x] = 1;
  }
  for (int i = 1; i <= n; i++)
    if (loop(i)) return puts("0"), 0;
  for (int i = 1; i <= n; i++)
    if (!p[i]) cnt_loop(i);
  for (int i = 1; i <= n; i++) {
    if (head[i]) t -= a[i];
    if (t < 0) break;
  }
  if (t < 0) return puts("0"), 0;
  dp[0] = 1;
  for (int i = 1; i <= n; i++)
    for (int j = 0; j <= t; j++)
      if (j + a[i] <= t) {
        dp[j + a[i]] += dp[j];
        if (dp[j + a[i]] >= 1000000007) dp[j + a[i]] -= 1000000007;
      }
  cout << dp[t] << '\n';
  return 0;
}
