#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:100000000000000")
using namespace std;
const long long int INF = 2e18;
vector<vector<long long int> > g;
vector<long long int> op;
vector<long long int> used;
long long int mod = 1000000007;
long long int dfs(long long int id, long long int now, long long int mode = 0) {
  used[id]++;
  long long int val = 0;
  if (g[id][1] != -1) {
    long long int to = g[id][1];
    val = dfs(to, now + (mode == 1 ? 1 : 0), mode);
  }
  if (val == (long long int)-1) return (long long int)-1;
  return (val + op[id] * now);
}
long long int dp[200001], temp[200001], prep[200001];
int main() {
  long long int n, q, t;
  cin >> n >> q >> t;
  op.resize(n);
  for (long long int i = 0; i < n; i++) cin >> op[i];
  long long int a, b;
  g.resize(n, vector<long long int>(2, -1));
  for (long long int i = 0; i < q; i++) {
    cin >> a >> b;
    a--;
    b--;
    g[a][0] = b;
    g[b][1] = a;
    if (g[a][0] == g[a][1]) {
      cout << 0;
      return 0;
    }
    if (g[b][0] == g[b][1]) {
      cout << 0;
      return 0;
    }
  }
  long long int temp = 0;
  used.assign(n, 0);
  for (long long int i = 0; i < n; i++) {
    if (g[i][0] == -1) {
      long long int ok = dfs(i, 0, 1);
      if (ok == (long long int)-1) {
        cout << 0;
        return 0;
      }
      temp += ok;
      if (temp > t) {
        cout << 0;
        return 0;
      }
    }
  }
  for (long long int i = 0; i < n; i++) {
    if (g[i][0] != -1 && !used[i]) {
      cout << 0;
      return 0;
    }
  }
  dp[temp] = 1;
  for (long long int j = 0; j < n; j++) {
    prep[j] = dfs(j, 1);
  }
  for (long long int i = 0; i < n; i++) {
    for (long long int j = temp; j <= t; j++) {
      if (j + prep[i] <= t) dp[j + prep[i]] = (dp[j + prep[i]] + dp[j]) % mod;
    }
  }
  cout << dp[t];
}
