#include <bits/stdc++.h>
using namespace std;
const int N = 303;
const int MOD = 1000000007;
int p[N];
int a[N];
int s[N];
bool vis[N];
int in[N];
int n, q, t;
bool flag;
int cnt = 0;
void dfs(int cur) {
  if (cur < 0 || cur >= n) {
    flag = false;
    return;
  }
  ++cnt;
  if (vis[cur]) {
    flag = false;
    return;
  }
  if (cnt > n + 1) {
    flag = false;
    return;
  }
  vis[cur] = 1;
  s[cur] = a[cur];
  if (p[cur] != -1) {
    dfs(p[cur]);
    s[cur] += s[p[cur]];
  }
}
int dp[100005];
int Ans() {
  if (!flag) return 0;
  for (int i = 0; i < n; ++i) {
    if (in[i]) t -= s[i];
    if (t < 0) return 0;
  }
  if (t < 0) return 0;
  if (t == 0) return 1;
  memset(dp, 0, sizeof(dp));
  for (int i = 0; i <= t; i += s[0]) dp[i] = 1;
  for (int i = 0; i < n - 1; ++i) {
    int x = s[i + 1];
    for (int j = 0; j + x <= t; ++j) {
      dp[j + x] += dp[j];
      if (dp[j + x] >= MOD) dp[j + x] -= MOD;
    }
  }
  return dp[t];
}
int main() {
  while (scanf("%d%d%d", &n, &q, &t) == 3) {
    for (int i = 0; i < n; ++i) {
      p[i] = -1;
      vis[i] = 0;
      in[i] = 0;
      scanf("%d", a + i);
    }
    int b, c;
    for (int i = 0; i < q; ++i) {
      scanf("%d%d", &b, &c);
      --b, --c;
      if (b < 0 || b >= n) return 0;
      if (c < 0 || c >= n) return 0;
      p[c] = b;
      ++in[b];
    }
    flag = true;
    for (int i = 0; i < n && flag; ++i) {
      memset(vis, 0, sizeof(vis));
      cnt = 0;
      dfs(i);
    }
    printf("%d\n", Ans());
  }
}
