#include <bits/stdc++.h>
using namespace std;
const int N = (int)3e2 + 10;
const int T = (int)1e5 + 10;
const int P = (int)1e9 + 7;
int n, m, t, a[N], dp[N][T];
long long d[N], w[N];
struct FunctionalGraph {
  int n, a[N], deg[N];
  FunctionalGraph(int n) : n(n) { memset(a, 0, sizeof a); };
  void AddEdge(int u, int v) {
    a[u] = v;
    deg[v]++;
  }
  int num[N], low[N], timer;
  bool fre[N], ans;
  stack<int> S;
  void DFS(int u) {
    num[u] = low[u] = ++timer;
    S.push(u);
    if (fre[a[u]]) {
      int v = a[u];
      if (num[v])
        low[u] = min(low[u], num[v]);
      else {
        DFS(v);
        low[u] = min(low[u], low[v]);
      }
    }
    if (num[u] == low[u]) {
      int v, c = 0;
      do {
        v = S.top();
        S.pop();
        fre[v] = false;
        c++;
      } while (v != u);
      if (c >= 2) ans = true;
    }
  }
  bool Acyclic() {
    memset(fre, true, sizeof fre);
    ans = false;
    for (int i = 1; i <= n; ++i)
      if (num[i] == 0) DFS(i);
    return ans;
  }
};
long long Weight(FunctionalGraph &G, int u) {
  if (d[u] != -1) return d[u];
  return d[u] = a[u] + Weight(G, G.a[u]);
}
int main() {
  scanf("%d%d%d", &n, &m, &t);
  assert(t > 0);
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
  static FunctionalGraph G(n);
  for (int i = 1; i <= m; ++i) {
    int u, v;
    scanf("%d%d", &v, &u);
    G.AddEdge(u, v);
  }
  if (G.Acyclic()) {
    puts("0");
    return 0;
  }
  long long dt = t;
  for (int i = 1; i <= n; ++i) d[i] = -1;
  for (int i = 1; i <= n; ++i) {
    w[i] = Weight(G, i);
    assert(w[i] > 0);
    if (G.deg[i]) dt -= w[i];
  }
  if (dt < 0) {
    puts("0");
    return 0;
  }
  dp[0][0] = 1;
  for (int i = 1; i <= n; ++i) {
    for (int j = 0; j <= dt; ++j) {
      dp[i][j] = dp[i - 1][j];
      if (j >= w[i]) dp[i][j] = (dp[i][j] + dp[i][j - w[i]]) % P;
    }
  }
  printf("%d", dp[n][dt]);
  return 0;
}
