#include <bits/stdc++.h>
using namespace std;
const int N = 3e2 + 5;
const int MOD = 1e9 + 7;
int n, q, w, a[N], du[N], sum[N];
vector<int> p[N];
bool v[N];
int dp[1 << 17];
bool dfs(int x, int cnt) {
  if (sum[x]) return sum[x];
  sum[x] = cnt + a[x];
  w = max(-1, w - cnt);
  for (int i = 0; i < p[x].size(); ++i)
    if (v[p[x][i]])
      return true;
    else {
      v[p[x][i]] = true;
      if (dfs(p[x][i], cnt + a[x])) return true;
      v[p[x][i]] = false;
    }
  return false;
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> q >> w;
  for (int i = 0; i < n; ++i) cin >> a[i];
  for (int i = 0; i < q; ++i) {
    int x, y;
    cin >> x >> y;
    --x, --y;
    p[x].push_back(y);
    ++du[y];
  }
  bool flag = false;
  for (int i = 0; !flag && i < n; ++i)
    if (!du[i]) flag = dfs(i, 0);
  for (int i = 0; !flag && i < n; ++i)
    if (sum[i] == 0) flag = true;
  if (flag || w < 0) {
    cout << 0 << endl;
    return 0;
  }
  dp[0] = 1;
  for (int i = 0; i < n; ++i) {
    for (int j = sum[i]; j <= w; ++j) dp[j] = (dp[j] + dp[j - sum[i]]) % MOD;
  }
  cout << dp[w] << endl;
  return 0;
}
