#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
void solve() {
  int n, q, t;
  cin >> n >> q >> t;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  vector<vector<int>> g(n);
  vector<int> in(n);
  for (int i = 0; i < q; i++) {
    int f, t;
    cin >> f >> t;
    f--;
    t--;
    g[f].push_back(t);
    in[t]++;
  }
  vector<int> used(n);
  function<void(int)> dfs = [&](int v) {
    used[v] = 1;
    for (int to : g[v]) {
      if (used[to] == 1) {
        cout << 0;
        exit(0);
      }
      if (used[to] == 0) dfs(to);
    }
    used[v] = 2;
  };
  for (int i = 0; i < n; i++) {
    if (!used[i]) dfs(i);
  }
  auto add = [&](int a, int b) { return ((long long)a + b + mod) % mod; };
  int ind = 0;
  vector<vector<vector<int>>> dp(2,
                                 vector<vector<int>>(t + 1, vector<int>(2, 0)));
  dp[0][0][0] = 1;
  function<void(int, int)> dfs2 = [&](int v, int sum) {
    for (int i = 0; i <= t; i++) {
      for (int k = 0; k < 2; k++) {
        dp[ind ^ 1][i][k] = 0;
      }
    }
    for (int i = 0; i <= t; i++) {
      if (sum) {
        if (i + sum + a[v] <= t) {
          dp[ind ^ 1][i + sum + a[v]][1] =
              add(dp[ind ^ 1][i + sum + a[v]][1], dp[ind][i][1]);
          dp[ind ^ 1][i + sum + a[v]][1] =
              add(dp[ind ^ 1][i + sum + a[v]][1], dp[ind ^ 1][i][1]);
        }
        dp[ind ^ 1][i][0] = add(dp[ind ^ 1][i][0], dp[ind][i][1]);
      } else {
        if (i + sum + a[v] <= t) {
          dp[ind ^ 1][i + sum + a[v]][1] =
              add(dp[ind ^ 1][i + sum + a[v]][1],
                  add(dp[ind][i][0], dp[ind][i][1]));
          dp[ind ^ 1][i + sum + a[v]][1] =
              add(dp[ind ^ 1][i + sum + a[v]][1], dp[ind ^ 1][i][1]);
        }
        dp[ind ^ 1][i][0] =
            add(dp[ind ^ 1][i][0], add(dp[ind][i][0], dp[ind][i][1]));
      }
    }
    for (int to : g[v]) {
      ind ^= 1;
      dfs2(to, sum + a[v]);
    }
  };
  for (int i = 0; i < n; i++) {
    if (in[i] == 0) {
      dfs2(i, 0);
      ind ^= 1;
    }
  }
  cout << add(dp[ind][t][0], dp[ind][t][1]);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int q = 1;
  for (; q > 0; q--) {
    solve();
  }
}
