#include <bits/stdc++.h>
using namespace std;
int n, q, t;
int a[300];
int gt[300];
int in[300];
bool vis[300];
int dp[2][200000 + 1];
const int MOD = 1000000007;
vector<int> topologicalSort() {
  vector<int> ret;
  bool update = true;
  while (update) {
    update = false;
    for (int i = 0; i < (int)(n); i++)
      if (!in[i] && !vis[i]) {
        ret.push_back(i);
        --in[gt[i]];
        vis[i] = true;
        update = true;
        break;
      }
  }
  return ret;
}
void dfs(int v, int acc) {
  if (vis[v]) return;
  vis[v] = true;
  t -= acc;
  if (t < 0) t = -1;
  a[v] += acc;
  if (~gt[v]) dfs(gt[v], a[v]);
}
int main() {
  cin >> n >> q >> t;
  for (int i = 0; i < (int)(n); i++) cin >> a[i];
  memset(gt, -1, sizeof(gt));
  for (int i = 0; i < (int)(q); i++) {
    int b, c;
    cin >> b >> c;
    gt[--b] = --c;
    ++in[c];
  }
  memset(vis, 0, sizeof(vis));
  vector<int> x = topologicalSort();
  if (x.size() < n) {
    cout << 0 << endl;
    return 0;
  }
  memset(vis, 0, sizeof(vis));
  for (int i = 0; i < (int)(n); i++) dfs(x[i], 0);
  if (t < 0) {
    cout << 0 << endl;
    return 0;
  }
  dp[0][0] = 1;
  for (int i = 0; i < (int)(n); i++) {
    int cur = i & 1;
    int nxt = (i + 1) & 1;
    memset(dp[nxt], 0, sizeof(dp[nxt]));
    for (int j = 0; j < (int)(t + 1); j++) {
      if (j + a[i] <= t)
        dp[cur][j + a[i]] = (dp[cur][j + a[i]] + dp[cur][j]) % MOD;
      dp[nxt][j] = (dp[nxt][j] + dp[cur][j]) % MOD;
    }
  }
  cout << dp[n & 1][t] << endl;
  return 0;
}
