#include <bits/stdc++.h>
using namespace std;
long long to[333], coin[111111], start[333], vis[333], n, t1, t2, t3, t;
vector<int> v;
int dp[2][111111];
const long long mod = 1000000007;
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> t1 >> t;
  for (int i(0), _n(n); i < _n; ++i) {
    cin >> coin[i];
  }
  memset(to, -1, sizeof(to));
  memset(start, 1, sizeof(start));
  for (int i(0), _n(t1); i < _n; ++i) {
    cin >> t2 >> t3;
    t2--;
    t3--;
    start[t3] = 0;
    to[t2] = t3;
  }
  t3 = 0;
  for (int i(0), _n(n); i < _n; ++i)
    if (start[i]) {
      t1 = i;
      t2 = 0;
      while (1) {
        vis[t1] = 1;
        t2 += coin[t1];
        v.push_back(t2);
        if (to[t1] != -1) t3 += t2;
        if (to[t1] == -1) break;
        t1 = to[t1];
      }
    }
  if (t3 > t) {
    cout << 0;
    return 0;
  }
  for (int i(0), _n(n); i < _n; ++i)
    if (!vis[i]) {
      cout << 0;
      return 0;
    }
  t -= t3;
  ;
  ;
  dp[0][0] = 1;
  for (int i(0), _n(((int)(v.size()))); i < _n; ++i)
    for (int j(0), _n(t + 1); j < _n; ++j) {
      dp[1 - (i & 1)][j] = dp[(i & 1)][j];
      if (j >= v[i]) dp[1 - (i & 1)][j] += dp[1 - (i & 1)][j - v[i]];
      dp[1 - (i & 1)][j] %= mod;
    }
  cout << dp[1 & ((int)(v.size()))][t] << endl;
}
