#include <bits/stdc++.h>
using namespace std;
int a[305], g[305][305], h[305], f[305];
long long DP[100020];
int n, q, t, x, y, i, j, z[305];
void go(int p, int u, int tmp) {
  if (f[u]) {
    cout << 0 << endl;
    exit(0);
  }
  f[u] = 1;
  int ans = 0;
  for (int i = 1; i <= n; i++)
    if (i != u && i != p && g[u][i]) {
      go(u, i, tmp + a[u]);
      h[u] = max(h[u], h[i] + 1);
      ans += a[i];
    }
  t -= h[u] * a[u];
  a[u] += tmp;
  if (t < 0) {
    cout << 0 << endl;
    exit(0);
  }
}
int main() {
  cin >> n >> q >> t;
  for (i = 1; i <= n; i++) cin >> a[i];
  for (i = 1; i <= q; i++) {
    cin >> x >> y;
    if (g[y][x]) {
      cout << 0 << endl;
      return 0;
    }
    g[x][y] = 1;
    z[y]++;
  }
  for (i = 1; i <= n; i++)
    if (!z[i]) go(0, i, 0);
  for (i = 1; i <= n; i++)
    if (!f[i]) {
      cout << 0 << endl;
      return 0;
    }
  DP[0] = 1;
  sort(a + 1, a + n + 1);
  for (j = 1; j <= n; j++)
    for (i = a[j]; i <= t; i++) DP[i] = (DP[i] + DP[i - a[j]]) % 1000000007;
  cout << DP[t] << endl;
  cin >> n;
}
