#include <bits/stdc++.h>
using namespace std;
vector<int> mat[100010];
int vis[100010], val[100010];
int dfs(int p, int pa) {
  if (vis[p]) return 1;
  int ret = 0;
  vis[p] = 1;
  if (p != pa) val[p] += val[pa];
  for (auto x : mat[p]) ret = max(ret, dfs(x, p));
  return ret;
}
int in[100010], out[100010], n, dp[302][100002][2];
int rec(int p, int r, int t) {
  if (p == n + 1) return (r == 0);
  if (r < 0) return 0;
  int &temp = dp[p][r][t];
  if (temp != -1) return temp;
  temp = 0;
  if (!out[p] || t) temp += rec(p + 1, r, 0);
  if (temp > 1000000007) temp -= 1000000007;
  temp += rec(p, r - val[p], 1);
  if (temp > 1000000007) temp -= 1000000007;
  return temp;
}
int main() {
  ios::sync_with_stdio(0);
  int q, t, u, v;
  cin >> n >> q >> t;
  for (int i = 1; i <= n; i++) cin >> val[i];
  for (int i = 0; i <= q - 1; i++) {
    cin >> u >> v;
    mat[u].push_back(v);
    in[v]++;
    out[u]++;
  }
  int chao = 0;
  for (int i = 1; i <= n; i++)
    if (!vis[i] && !in[i]) chao = max(chao, dfs(i, i));
  for (int i = 1; i <= n; i++)
    if (!vis[i]) chao = 1;
  memset(dp, -1, sizeof(dp));
  if (chao)
    cout << 0 << endl;
  else
    cout << rec(1, t, 0) << endl;
  return 0;
}
