#include <bits/stdc++.h>
using namespace std;
long long n, q, t, a[333], x, y, ch, w[333], d[111111] = {1}, sz, b[333],
                                             c[333];
vector<long long> v[333];
void dff(long long x) {
  w[x] = 1;
  for (long long i = 0; i < v[x].size(); i++) {
    long long to = v[x][i];
    if (!w[to]) dff(to);
  }
  c[sz--] = x;
}
void dfs(long long x, long long sum) {
  w[x] = 1;
  t -= sum;
  b[++sz] = sum + a[x];
  for (long long i = 0; i < v[x].size(); i++) {
    long long to = v[x][i];
    if (!w[to])
      dfs(to, sum + a[x]);
    else if (w[to] == 1)
      ch = 1;
  }
  w[x] = 2;
}
int main() {
  cin >> n >> q >> t;
  for (long long i = 1; i <= n; i++) cin >> a[i];
  for (long long i = 1; i <= q; i++) cin >> x >> y, v[x].push_back(y);
  sz = n;
  for (long long i = 1; i <= n; i++)
    if (!w[i]) dff(i);
  for (long long i = 1; i <= n; i++) w[i] = 0;
  for (long long i = 1; i <= n; i++)
    if (!w[c[i]]) dfs(c[i], 0);
  if (ch) {
    cout << 0;
    return 0;
  }
  if (t < 0) {
    cout << 0;
    return 0;
  }
  for (long long i = 1; i <= n; i++)
    for (long long j = b[i]; j <= t; j++)
      d[j] += d[j - b[i]], d[j] %= 1000000007;
  cout << d[t];
}
