#include <bits/stdc++.h>
using namespace std;
inline int M(int x) { return (x >= 1000000007) ? (x - 1000000007) : x; }
int n, m, K, a[100127], f[100127], son[100127], fa[100127];
bool vis[100127];
int main() {
  scanf("%d%d%d", &n, &K, &m);
  int i, j, x, y;
  for (i = 1; i <= n; i++) scanf("%d", &a[i]);
  while (K--) {
    scanf("%d%d", &x, &y);
    son[x] = y;
    fa[y] = x;
  }
  for (i = 1; i <= n; i++)
    if (!fa[x = i]) {
      y = son[x];
      vis[x] = 1;
      while (y) {
        vis[y] = 1;
        m -= a[x];
        if (m < 0) {
          printf("0");
          return 0;
        }
        a[y] += a[x];
        x = y;
        y = son[y];
      }
    }
  for (x = 1; x <= n; x++)
    if (!vis[x]) {
      printf("0");
      return 0;
    }
  f[0] = 1;
  for (i = 1; i <= n; i++)
    for (j = a[i]; j <= m; j++) f[j] = M(f[j] + f[j - a[i]]);
  printf("%d", f[m]);
  return 0;
}
