#include <bits/stdc++.h>
using namespace std;
inline int max(int a, int b) { return a > b ? a : b; }
inline int min(int a, int b) { return a < b ? a : b; }
inline int gcd(int a, int b) {
  if (a % b)
    return gcd(b, a % b);
  else
    return b;
}
inline int lcm(int a, int b) { return (a * (b / gcd(a, b))); }
inline int And(int mask, int bit) { return mask & (1 << bit); }
inline int Or(int mask, int bit) { return mask | (1 << bit); }
inline int Xor(int mask, int bit) { return mask & (~(1 << bit)); }
int a[333], deg[333], mark[333];
int n, q, u, v, x, y;
bool circle;
vector<int> adj[333], topo;
long long dp[333][100111], w[333], t;
void dfs(int u) {
  if (mark[u]) return;
  mark[u] = 1;
  w[u] = a[u];
  for (int i = 0; i < adj[u].size(); i++) {
    dfs(adj[u][i]);
    w[u] += w[adj[u][i]];
  }
  topo.push_back(w[u]);
}
int main() {
  scanf("%d %d %I64d", &n, &q, &t);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    deg[i] = mark[i] = 0;
  }
  for (int i = 1; i <= q; i++) {
    scanf("%d %d", &u, &v);
    adj[v].push_back(u);
    deg[u]++;
  }
  circle = false;
  for (int i = 1; i <= n; i++)
    if (deg[i] == 0) {
      x = topo.size();
      dfs(i);
      y = topo.size();
      for (int i = x; i < y - 1; i++) t -= topo[i];
      if (t < 0) {
        circle = true;
        break;
      }
    }
  for (int i = 1; i <= n; i++)
    if (mark[i] == 0) {
      circle = true;
      break;
    }
  if (circle)
    puts("0");
  else {
    dp[0][0] = 1;
    for (int i = 1; i <= n; i++)
      for (int j = 0; j <= t; j++) {
        dp[i][j] = dp[i - 1][j];
        if (j >= topo[i - 1]) dp[i][j] += dp[i][j - topo[i - 1]];
        dp[i][j] %= 1000000007;
      }
    printf("%I64d\n", dp[n][t]);
  }
  return 0;
}
