#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e2 + 10;
const int maxs = 1e5 + 10;
const int mod = 1e9 + 7;
long long a[maxn], sum, cnt[maxn], in[maxn], dp[maxn][maxs];
vector<long long> v, g[maxn];
bool visited[maxn], visited2[maxn], dor;
int dfs(int x) {
  visited2[x] = 1;
  int ans = 0;
  ans += a[x];
  for (int i : g[x]) {
    if (!visited2[i]) {
      ans += dfs(i);
    } else {
      dor = 1;
    }
  }
  return ans;
}
void dfs2(int x) {
  visited[x] = 1;
  sum += a[x] * cnt[x];
  for (int i : g[x]) {
    in[i]--;
    cnt[i] = max(cnt[x] + 1, cnt[i]);
    if (in[i] == 0) {
      dfs2(i);
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long n, m, t;
  cin >> n >> m >> t;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    in[a]++;
    g[b].push_back(a);
  }
  v.push_back(0);
  for (int i = 1; i <= n; i++) {
    v.push_back(dfs(i));
    if (dor) {
      cout << 0;
      return 0;
    }
    for (int j = 1; j <= n; j++) {
      visited2[j] = 0;
    }
  }
  for (int i = 1; i <= n; i++) {
    if (in[i] == 0 && !visited[i]) {
      dfs2(i);
    }
  }
  if (sum == t) {
    cout << 1;
    return 0;
  }
  if (sum > t) {
    cout << 0;
    return 0;
  }
  for (int i = 0; i <= n; i++) {
    dp[i][0] = 1;
  }
  for (int i = 1; i <= t - sum; i++) {
    for (int j = 1; j <= n; j++) {
      dp[j][i] = dp[j - 1][i] + dp[j][i - v[j]];
      dp[j][i] = dp[j][i] % mod;
    }
  }
  cout << dp[n][t - sum];
}
