#include <bits/stdc++.h>
using namespace std;
const int N = 200010;
const long long inf = 0x3f3f3f3f3f3f3f3fll;
const int mod = 1e9 + 7;
int ch[310], a[310], d[310];
bool vis[310];
int dp[2][N];
int main() {
  int n, q, t;
  scanf("%d%d%d", &n, &q, &t);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  for (int i = 0; i < q; i++) {
    int b, c;
    scanf("%d%d", &b, &c);
    ch[b] = c;
    d[c]++;
  }
  for (int i = 1; i <= n; i++) {
    if (d[i]) continue;
    int t = i;
    while (t) {
      vis[t] = 1;
      t = ch[t];
    }
  }
  for (int i = 1; i <= n; i++)
    if (!vis[i]) return puts("0"), 0;
  int x = 0;
  dp[0][0] = 1;
  for (int k = 1; k <= n; k++) {
    if (d[k]) continue;
    vector<int> vt;
    int T = k;
    while (T) {
      vt.push_back(T);
      T = ch[T];
    }
    long long p = 0;
    long long j = 0;
    for (int i = 0; i < vt.size(); i++) j += a[vt[i]], p += j, a[vt[i]] = j;
    p -= j;
    if (p > t) return puts("0"), 0;
    for (int i = 0; i <= t - p; i++) dp[x ^ 1][i + p] = dp[x][i];
    for (int i = 0; i < vt.size(); i++) {
      for (int j = 0; j <= t - a[vt[i]]; j++) {
        if (dp[x ^ 1][j])
          dp[x ^ 1][j + a[vt[i]]] =
              (dp[x ^ 1][j + a[vt[i]]] + dp[x ^ 1][j]) % mod;
      }
    }
    memset(dp[x], 0, sizeof(dp[x]));
    x ^= 1;
  }
  cout << dp[x][t] << endl;
  return 0;
}
