#include <bits/stdc++.h>
using namespace std;
const int maxn = 303, maxt = 1e5 + 50, MOD = 1e9 + 7;
int tval[maxn], nxt[maxn], val[maxn], dp[maxt];
bool vis[maxn], in[maxn];
int n, q, tot;
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> q >> tot;
  for (int i = 0; i < n; i++) {
    cin >> tval[i];
    nxt[i] = i;
  }
  for (int i = 0; i < q; i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    nxt[a] = b;
    in[b] = true;
  }
  for (int i = 0; i < n; i++) {
    if (!vis[i] && !in[i]) {
      int cur = i, curSum = 0;
      for (; nxt[cur] != cur; cur = nxt[cur]) {
        if (vis[cur]) {
          return 0;
        }
        vis[cur] = true;
        curSum += tval[cur];
        tot -= curSum;
        if (tot < 0) {
          cout << "0\n";
          return 0;
        }
        val[cur] = curSum;
      }
      curSum += tval[cur];
      vis[cur] = true;
      val[cur] = curSum;
    }
  }
  for (int i = 0; i < n; i++) {
    if (!vis[i]) {
      cout << "0\n";
      return 0;
    }
  }
  dp[0] = 1;
  for (int i = 0; i < n; i++) {
    for (int c = 0; c <= tot - val[i]; c++) {
      dp[c + val[i]] = (dp[c + val[i]] + dp[c]) % MOD;
    }
  }
  cout << dp[tot] << '\n';
  return 0;
}
