#include <bits/stdc++.h>   using namespace std;   template <class T>   inline void chkmin(T &a, T b) {     if (a > b) a = b;   }   template <class T>   inline void chkmax(T &a, T b) {     if (a < b) a = b;   }   inline int read() {     int s = 0, f = 1;     char ch = getchar();     while (!isdigit(ch) && ch !=  - ) ch = getchar();     if (ch ==  - ) ch = getchar(), f = -1;     while (isdigit(ch)) s = s * 10 + ch -  0 , ch = getchar();     return ~f ? s : -s;   }   const int maxn = 1e5 + 20;   int n, q, t;   long long now;   int fa[maxn], to[maxn];   int a[maxn];   int f[maxn], vis[maxn];   inline void init() {     n = read();     q = read();     t = read();     for (int i = (1), _end_ = (n); i <= _end_; i++) a[i] = read();     for (int i = (1), _end_ = (q); i <= _end_; i++) {       int x = read(), y = read();       to[x] = y;       fa[y] = x;     }     for (int i = (1), _end_ = (n); i <= _end_; i++)       if (!fa[i]) {         int x = i;         while (to[x]) {           if (vis[x]) puts( 0 ), exit(0);           vis[x] = 1;           now += a[x];           a[to[x]] += a[x];           x = to[x];         }         vis[x] = 1;       }     for (int i = (1), _end_ = (n); i <= _end_; i++)       if (!vis[i]) puts( 0 ), exit(0);   }   const int mod = 1e9 + 7;   inline void pls(int &a, int b) {     a += b;     a -= a >= mod ? mod : 0;   }   inline void doing() {     f[0] = 1;     for (int j = (1), _end_ = (n); j <= _end_; j++) {       for (int i = a[j]; i <= t - now; i++) pls(f[i], f[i - a[j]]);     }     if (now <= t)       printf( %d n , f[t - now]);     else       puts( 0 );   }   int main() {     init();     doing();     return 0;   }   