#include <bits/stdc++.h>
using namespace std;
const int maxn = 300 + 5;
const int mod = 1e9 + 7;
const int maxsum = 1e5 + 5;
int n, value[maxn], q, sum, a, b, dp[maxsum], degree[maxn];
vector<int> adj[maxn], adjReverse[maxn], top;
bool mark[maxn], last[maxn];
void dfs(int curr) {
  mark[curr] = true;
  for (vector<int>::iterator it = adj[curr].begin(); it != adj[curr].end();
       it++) {
    value[*it] += value[curr];
    dfs(*it);
  }
  if (adj[curr].empty()) last[curr] = true;
}
int main() {
  scanf("%d %d %d", &n, &q, &sum);
  for (int i = 0; i < n; i++) scanf("%d", &value[i]);
  for (int i = 0; i < q; i++) {
    scanf("%d %d", &a, &b);
    adj[a - 1].push_back(b - 1);
    adjReverse[b - 1].push_back(a - 1);
    degree[a - 1]++;
  }
  while (top.size() < n) {
    int idx = 0;
    while (degree[idx]) idx++;
    if (idx == n) {
      printf("0\n");
      return 0;
    }
    top.push_back(idx);
    degree[idx] = -1;
    for (vector<int>::iterator it = adjReverse[idx].begin();
         it != adjReverse[idx].end(); it++)
      degree[*it]--;
  }
  for (vector<int>::reverse_iterator it = top.rbegin(); it != top.rend(); it++)
    if (!mark[*it]) dfs(*it);
  for (int i = 0; i < n; i++)
    if (!last[i]) {
      sum -= value[i];
      if (sum < 0) {
        printf("0\n");
        return 0;
      }
    }
  dp[0] = 1;
  for (int i = 0; i < n; i++)
    for (int j = value[i]; j <= sum; j++)
      dp[j] = (dp[j] + dp[j - value[i]]) % mod;
  printf("%d\n", dp[sum]);
  return 0;
}
