#include <bits/stdc++.h>
using namespace std;
const int N = (int)1e5 + 7;
const int M = (int)1e9 + 7;
int n, q, t;
int a[N];
int b[N];
int c[N];
int to[N];
int sec[N];
int dp[301][N];
int used[N];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> q >> t;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  memset(to, -1, sizeof(to));
  for (int i = 1; i <= q; i++) {
    cin >> b[i] >> c[i];
    to[b[i]] = c[i];
    sec[c[i]] = true;
  }
  vector<int> new_coins;
  long long tot = 0;
  for (int i = 1; i <= n; i++) {
    if (sec[i] == false) {
      int x = i;
      int s = 0;
      while (1) {
        used[x] = true;
        s += a[x];
        new_coins.push_back(s);
        if (to[x] != -1)
          tot += s;
        else
          break;
        x = to[x];
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    if (!used[i]) {
      cout << 0 << '\n';
      return 0;
    }
  }
  if (tot > t) {
    cout << 0 << '\n';
    return 0;
  }
  t -= tot;
  dp[0][0] = 1;
  for (int i = 0; i < new_coins.size(); i++) {
    for (int j = 0; j <= t; j++) {
      dp[i + 1][j] = dp[i][j];
      if (j >= new_coins[i]) {
        dp[i + 1][j] = (dp[i + 1][j] + dp[i + 1][j - new_coins[i]]) % M;
      }
    }
  }
  cout << dp[new_coins.size()][t] << '\n';
  return 0;
}
