#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
long long lit[300 + 2], n, q, t, a[300 + 2];
long long d[300 + 2][100 * 1000 + 3];
bool root[300 + 2], mark[300 + 2];
void dfs(int v);
int main() {
  cin >> n >> q >> t;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 0; i < q; i++) {
    long long b, c;
    cin >> b >> c;
    lit[b] = c;
  }
  fill(root + 1, root + n + 1, true);
  for (int i = 1; i <= n; i++) root[lit[i]] = false;
  for (int i = 1; i <= n; i++)
    if (root[i]) dfs(i);
  if (t < 0) {
    cout << 0 << '\n';
    return 0;
  }
  for (int i = 1; i <= n; i++)
    if (!mark[i]) {
      cout << 0 << '\n';
      return 0;
    }
  d[0][0] = 1;
  for (int i = 1; i <= n; i++)
    for (int j = 0; j <= t; j++) {
      if (a[i] <= j) d[i][j] = d[i][j - a[i]];
      d[i][j] += d[i - 1][j];
      d[i][j] %= mod;
    }
  cout << d[n][t] << '\n';
  return 0;
}
void dfs(int v) {
  mark[v] = true;
  if (lit[v]) {
    t -= a[v];
    a[lit[v]] += a[v];
    dfs(lit[v]);
  }
}
