#include <bits/stdc++.h>
using namespace std;
int const M = 2e5 + 10, mod = 1e9 + 7;
int a[M], c[M], dp[2][2][M], mark[M], child[M], p[M];
int dfs(int v) {
  mark[v] = 1;
  if (!child[v]) return a[v];
  if (mark[child[v]]) {
    cout << 0;
    exit(0);
  }
  a[v] += dfs(child[v]);
  return a[v];
}
void fdp(int i, int j, int k) {
  dp[k][i % 2][j] = 0;
  if (j >= a[i]) dp[k][i % 2][j] = dp[1][i % 2][j - a[i]];
  if (k == 1) {
    int tmp = 0;
    if (p[i + 1] == 0) tmp = 1;
    dp[k][i % 2][j] += dp[tmp][1 - (i % 2)][j];
  }
  dp[k][i % 2][j] %= mod;
}
int main() {
  int n, q, t;
  cin >> n >> q >> t;
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  while (q--) {
    int tmp1, tmp2;
    scanf("%d%d", &tmp1, &tmp2);
    child[tmp2] = tmp1;
    p[tmp1] = tmp2;
  }
  for (int i = 1; i <= n; i++) {
    if (!mark[i] && !p[i]) {
      dfs(i);
    }
  }
  for (int i = 1; i <= n; i++) {
    if (!mark[i]) {
      cout << 0;
      exit(0);
    }
  }
  dp[1][(n + 1) % 2][0] = 1;
  dp[0][(n + 1) % 2][0] = 1;
  for (int i = n; i >= 1; i--) {
    for (int j = 0; j <= t; j++) {
      for (int k = 0; k <= 1; k++) {
        fdp(i, j, k);
      }
    }
  }
  if (!p[1])
    cout << dp[1][1][t];
  else
    cout << dp[0][1][t];
}
