#include <bits/stdc++.h>
using namespace std;
int n, q, t;
int memo[310][100010];
int val[310];
vector<int> a[310];
int visited[310];
bool canstart[310];
int cnt = 0;
int p = 1e9 + 7;
void dfs(int u) {
  visited[u] = cnt;
  for (int i = 0; i < a[u].size(); i++) {
    int v = a[u][i];
    if (visited[v] == cnt) {
      cout << 0;
      exit(0);
    }
    if (visited[v] == 0) dfs(v);
    val[u] += val[v];
  }
}
int solve(int in, int remain) {
  if (remain < 0) return 0;
  if (in == n + 1 && remain == 0) return 1;
  if (in == n + 1) return 0;
  if (memo[in][remain] != -1) return memo[in][remain];
  int cur;
  if (canstart[in] == 1) {
    cur = (solve(in + 1, remain - val[in]) + solve(in, remain - val[in])) % p;
  } else {
    cur = (solve(in + 1, remain) + solve(in, remain - val[in])) % p;
  }
  return memo[in][remain] = cur;
}
int main() {
  cin >> n >> q >> t;
  for (int i = 1; i <= n; i++) cin >> val[i];
  for (int i = 1; i <= q; i++) {
    int u, v;
    cin >> u >> v;
    a[v].push_back(u);
    canstart[u] = 1;
  }
  for (int i = 1; i <= n; i++) {
    if (canstart[i] == 0) {
      ++cnt;
      dfs(i);
    }
  }
  for (int i = 1; i <= n; i++) {
    if (visited[i] == 0) {
      cout << 0;
      exit(0);
    }
  }
  memset(memo, -1, sizeof(memo));
  cout << solve(1, t) << "\n";
}
