#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
void init();
void dp();
void makesf();
int dfs(int);
int N, Q, T, a[302], ca[302], w[100010];
int s[302], f[302];
bool vi[302];
int initcount[302];
bool FLAG = 0;
int main() {
  init();
  dp();
  return 0;
}
void init() {
  memset(a, 0, sizeof(a));
  memset(f, 0, sizeof(f));
  memset(s, 0, sizeof(s));
  memset(initcount, 0, sizeof(initcount));
  memset(w, 0, sizeof(w));
  w[0] = 1;
  cin >> N >> Q >> T;
  for (int i = (1); i <= (N); i++) cin >> ca[i];
  for (int i = (1); i <= (Q); i++) {
    int b, c;
    cin >> b >> c;
    s[b] = c;
    f[c] = b;
  }
}
void dp() {
  makesf();
  if (FLAG) {
    cout << 0 << endl;
    return;
  }
  for (int i = (1); i <= (N); i++) {
    T -= initcount[i] * ca[i];
    if (T < 0) {
      cout << 0 << endl;
      return;
    }
  }
  for (int i = (1); i <= (N); i++)
    for (int j = (a[i]); j <= (T); j++) w[j] = (w[j - a[i]] + w[j]) % MOD;
  cout << w[T] << endl;
  return;
}
void DFS(int x) {
  vi[x] = 1;
  if (s[x] == 0) return;
  DFS(s[x]);
}
int dfs(int x) {
  vi[x] = 1;
  if (s[x] == 0) return initcount[x] = 0;
  return initcount[x] = dfs(s[x]) + 1;
}
int dfs2(int x) {
  vi[x] = 1;
  if (f[x] == 0) return a[x] = ca[x];
  return a[x] = dfs2(f[x]) + ca[x];
}
void makesf() {
  memset(vi, 0, sizeof(vi));
  for (int i = (1); i <= (N); i++)
    if (!vi[i] && f[i] == 0) DFS(i);
  for (int i = (1); i <= (N); i++)
    if (!vi[i]) FLAG = 1;
  if (FLAG) return;
  memset(vi, 0, sizeof(vi));
  for (int i = (1); i <= (N); i++)
    if (!vi[i]) initcount[i] = dfs(i);
  memset(vi, 0, sizeof(vi));
  for (int i = (1); i <= (N); i++)
    if (!vi[i]) a[i] = dfs2(i);
  return;
}
