#include <bits/stdc++.h>
using namespace std;
const int MAXN = 300 + 5;
const int Mod = 1e9 + 7;
int n, q, t;
int to[MAXN], fr[MAXN], val[MAXN];
int f[1000010] = {1};
bool ero, vis[MAXN];
void dfs(int x) {
  vis[x] = true;
  if (!to[x]) return;
  val[to[x]] += val[x];
  dfs(to[x]);
  t -= val[x];
  if (t < 0) ero = true;
}
int main() {
  cin >> n >> q >> t;
  for (int i = 1; i <= n; ++i) cin >> val[i];
  for (int i = 1, x, y; i <= q; ++i) {
    cin >> x >> y;
    to[x] = y;
    fr[y] = x;
  }
  for (int i = 1; i <= n; ++i)
    if (!fr[i]) dfs(i);
  for (int i = 1; i <= n; ++i)
    if (!vis[i]) ero = true;
  if (ero) {
    cout << "0";
    return 0;
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 0; j + val[i] <= t; ++j)
      f[j + val[i]] = (f[j + val[i]] + f[j]) % Mod;
  }
  cout << f[t] << endl;
  return 0;
}
