#include <bits/stdc++.h>   using namespace std;   long long in() {     int32_t x;     scanf( %d , &x);     return x;   }   const long long maxn = 1e5 + 10;   const long long mod = 1e9 + 7;   const long long inf = 1e9 + 10;   vector<long long> g[maxn];   long long deg[maxn];   long long a[maxn];   bool mark[maxn];   long long rem;   vector<long long> path, V;   inline void dfs(long long node) {     mark[node] = true;     rem--;     path.push_back(node);     for (auto u : g[node]) {       if (mark[u]) {         cout << 0 << endl;         exit(0);       }       dfs(u);     }   }   long long dp[maxn];   int32_t main() {     long long n = in(), q = in(), t = in();     rem = n;     for (long long i = 0; i < n; i++) a[i] = in();     for (long long i = 0; i < q; i++) {       long long from = in() - 1, to = in() - 1;       g[from].push_back(to);       deg[to]++;     }     V.push_back(0);     dp[0] = 1;     for (long long i = 0; i < n; i++) {       if (!mark[i] && !deg[i]) {         path.clear();         dfs(i);         long long prefsum = 0;         for (auto v : path) {           prefsum += a[v];           V.push_back(prefsum);           if (v - path.back()) t -= prefsum;         }       }     }     if (rem) return cout << 0 << endl, 0;     if (t < 0) return cout << 0 << endl, 0;     for (long long i = 1; i < V.size(); i++) {       for (long long pre = 0; pre + V[i] < maxn; pre++)         (dp[pre + V[i]] += dp[pre]) %= mod;     }     cout << dp[t] << endl;   }   