#include <bits/stdc++.h>
using namespace std;
int n, q;
long long int t;
int v[310], m[310][310], vis[310];
vector<long long int> ncoins;
long long int pd[100010];
int DFS(int vex, long long int sum) {
  int i;
  vis[vex] = 1;
  sum += v[vex];
  ncoins.push_back(sum);
  if (m[vex][n + 1] != 0) {
    t -= sum;
    for (i = 1; i <= n; i++)
      if (m[vex][i]) {
        if (vis[i])
          return -1;
        else if (DFS(i, sum) == -1)
          return -1;
      }
  }
  return 0;
}
int main(void) {
  int i, j, f, a, b;
  while (scanf("%d %d", &n, &q) != EOF) {
    cin >> t;
    for (i = 1; i <= n; i++) scanf("%d", &v[i]);
    for (i = 0; i <= n; i++)
      for (j = 0; j <= n + 1; j++) vis[i] = m[i][j] = 0;
    ncoins.clear();
    for (i = 0; i < q; i++) {
      scanf("%d %d", &a, &b);
      m[a][b] = 1;
      m[b][0]++;
      m[a][n + 1]++;
    }
    f = 1;
    for (i = 1; i <= n; i++)
      if (!vis[i] && m[i][0] == 0) {
        if (DFS(i, 0) == -1) {
          f = 0;
          break;
        }
      }
    for (i = 1; f && i <= n; i++)
      if (!vis[i]) {
        f = 0;
        break;
      }
    if (f && t >= 0) {
      for (i = 0; i <= t; i++) pd[i] = 0;
      pd[0] = 1;
      for (i = 0; i < ncoins.size(); i++)
        for (j = 0; j <= t; j++)
          if (pd[j])
            pd[j + ncoins[i]] = (pd[j] + pd[j + ncoins[i]]) % 1000000007;
      cout << pd[t] << endl;
    } else {
      printf("0\n");
    }
  }
  return 0;
}
