#include <bits/stdc++.h>
using namespace std;
const int M = 300 + 10;
long long int mod = 1000000007;
long long int a[M];
int indg[M];
int flag[M];
int flag2[M];
vector<int> adj[M];
long long int dp[2][100000 + 10];
int n, q;
long long int t;
long long int lastpre = 0;
void dfs(int cur, long long int pre) {
  pre = pre + a[cur];
  a[cur] = pre;
  t -= pre;
  lastpre = pre;
  for (int i = 0; i < adj[cur].size(); i++) {
    int nxt = adj[cur][i];
    dfs(nxt, pre);
  }
}
bool hasloop = false;
void isloop(int cur) {
  if (flag2[cur] == 1) {
    hasloop = true;
  } else {
    flag2[cur] = 1;
    for (int i = 0; i < adj[cur].size(); i++) {
      isloop(adj[cur][i]);
    }
  }
}
int main() {
  time_t t_start, t_end;
  t_start = clock();
  cin >> n >> q >> t;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < q; i++) {
    int u, v;
    cin >> u >> v;
    indg[v]++;
    adj[u].push_back(v);
    flag[u] = flag[v] = 1;
  }
  for (int i = 1; i <= n; i++) {
    if (flag2[i] == 0 && indg[i] == 0 && !adj[i].empty()) {
      isloop(i);
    }
  }
  for (int i = 1; i <= n; i++) {
    if (flag[i] == 1 && flag2[i] == 0) {
      hasloop = true;
    }
  }
  if (hasloop) {
    cout << 0 << endl;
  } else {
    for (int i = 1; i <= n; i++) {
      if (indg[i] == 0 && adj[i].size() > 0) {
        dfs(i, 0);
        t += lastpre;
        lastpre = 0;
      }
    }
    if (t < 0) {
      cout << 0 << endl;
    } else {
      int mo = 0;
      dp[0][0] = 1;
      for (int i = 1; i <= n; i++) {
        dp[1 - mo][0] = 1;
        for (int j = 1; j <= t; j++) {
          dp[1 - mo][j] = 0;
          long long int val1 = dp[mo][j];
          long long int val2 = 0;
          if (j - a[i] >= 0) {
            val2 = dp[1 - mo][j - a[i]];
          }
          dp[1 - mo][j] = (val1 + val2) % mod;
        }
        mo = 1 - mo;
      }
      cout << dp[mo][(int)t] << endl;
    }
  }
  t_end = clock();
  return 0;
}
