#include <bits/stdc++.h>
using namespace std;
const int maxn = 316, maxt = 1000 * 100 + 16, mod = 1000 * 1000 * 1000 + 7;
vector<int> topol;
bool seen[maxn], ini[maxn], outi[maxn], mark[maxn][maxt];
int N, Q, T, prv[maxn], coin[maxn], dp[maxn][maxt], C[maxn];
bool dfs(int i) {
  if (seen[i]) return 0;
  seen[i] = 1;
  if (!ini[i]) {
    topol.push_back(i);
    return 1;
  }
  int v = prv[i];
  coin[v] += coin[i];
  bool ret = 0;
  if (!ini[i])
    ret = 1;
  else
    ret = dfs(v);
  topol.push_back(i);
  return ret;
}
long long dpis(int n, int t) {
  if (t < 0 || n >= N) return 0;
  if (mark[n][t]) return dp[n][t];
  mark[n][t] = 1;
  if (n == N - 1) {
    if (t % coin[topol[n]] == 0) return dp[n][t] = 1;
    return dp[n][t] = 0;
  }
  return dp[n][t] = (dpis(n + 1, t - coin[topol[n]] + C[topol[n]]) +
                     dpis(n, t - coin[topol[n]])) %
                    mod;
}
int main() {
  cin >> N >> Q >> T;
  for (int i = 0; i < N; i++) {
    cin >> coin[i];
    C[i] = coin[i];
  }
  while (Q--) {
    int u, v;
    cin >> u >> v;
    u--, v--;
    prv[u] = v;
    ini[u] = 1, outi[v] = 1;
  }
  for (int i = 0; i < N; i++) {
    if (!ini[i] and !outi[i]) {
      seen[i] = 1;
      topol.push_back(i);
      continue;
    }
    if (!seen[i] and !outi[i] and !dfs(i)) {
      cout << "0\n";
      return 0;
    }
  }
  for (int i = 0; i < N; i++)
    if (!seen[i]) {
      cout << "0\n";
      return 0;
    }
  cout << dpis(0, T) << endl;
  return 0;
}
