#include <bits/stdc++.h>
using namespace std;
const int M = 1e5 + 10;
long long a[400], num[400], dp[M];
int to[400], pre[400];
vector<int> vc[400];
void dfs(int pos, int cnt) {
  vc[cnt].push_back(pos);
  if (to[pos] == -1) return;
  dfs(to[pos], cnt);
}
int main() {
  int n, q, t, u, v;
  scanf("%d%d%d", &n, &q, &t);
  for (int i = 1; i <= n; i++) {
    scanf("%I64d", &a[i]);
    to[i] = -1;
    pre[i] = -1;
  }
  while (q--) {
    scanf("%d%d", &u, &v);
    to[u] = v;
    pre[v] = u;
  }
  int count = 0;
  for (int i = 1; i <= n; i++) {
    if (pre[i] == -1) {
      dfs(i, count);
      count++;
    }
  }
  long long sta = 0;
  int tot = 0;
  for (int i = 0; i < count; i++) {
    int len = vc[i].size();
    tot += len;
    long long sum = 0;
    for (int j = 0; j < len; j++) {
      int pos = vc[i][j];
      sum += a[pos];
      num[pos] = sum;
    }
    sum = 0;
    if (len > 1) {
      for (int j = 0; j < len - 1; j++) {
        int pos = vc[i][j];
        sum += a[pos];
        sta += sum;
      }
    }
  }
  memset(dp, 0, sizeof(dp));
  if (sta <= t && tot == n) {
    dp[sta] = 1;
    for (int i = 0; i < count; i++) {
      int len = vc[i].size();
      for (int j = 0; j < len; j++) {
        int pos = vc[i][j];
        for (int k = (int)max(sta, num[pos]); k <= t; k++) {
          dp[k] += dp[k - num[pos]];
          dp[k] %= 1000000007;
        }
      }
    }
  }
  printf("%I64d\n", dp[t] % 1000000007);
  return 0;
}
