#include <bits/stdc++.h>
using namespace std;
struct point {
  set<int> s;
};
point d[305];
int n, q, wart[305], tab[305][305], x, y, a, pocz, kon, k, odw[305],
    kolejka[100005], tabk[305], nowe[305];
long long dyn[100005], t;
void rob() {
  set<int>::iterator it;
  for (int i = 1; i <= n; i++)
    for (it = d[i].s.begin(); it != d[i].s.end(); it++) nowe[i] += wart[*it];
  dyn[0] = 1;
  for (int i = 1; i <= n; i++)
    for (int j = 0; j <= t - nowe[i]; j++) {
      dyn[j + nowe[i]] += dyn[j];
      dyn[j + nowe[i]] %= 1000000007;
    }
  cout << dyn[t] << endl;
}
bool bfs(int u) {
  x = 0;
  kolejka[0] = u;
  pocz = 0;
  kon = 0;
  for (int i = 1; i <= n; i++) odw[i] = 0;
  while (pocz <= kon) {
    k = kolejka[pocz];
    x++;
    d[k].s.insert(u);
    for (int i = 1; i <= n; i++)
      if (tab[k][i] == 1) {
        if (i == u) return 1;
        if (odw[i] == 0) {
          kon++;
          kolejka[kon] = i;
          odw[i] = 1;
        }
      }
    pocz++;
  }
  x--;
  tabk[u] = x;
  return 0;
}
bool zmniejszt() {
  for (int i = 1; i <= n; i++) {
    t -= tabk[i] * wart[i];
    if (t < 0) {
      printf("0\n");
      return 1;
    }
  }
  return 0;
}
void dzialaj() {
  for (int i = 1; i <= n; i++) {
    a = bfs(i);
    if (a == 1) {
      printf("0\n");
      return;
    }
  }
  a = zmniejszt();
  if (a == 1) return;
  rob();
}
int main() {
  scanf("%d %d", &n, &q);
  cin >> t;
  for (int i = 1; i <= n; i++) scanf("%d", &wart[i]);
  for (int i = 0; i < q; i++) {
    scanf("%d %d", &x, &y);
    tab[x][y] = 1;
  }
  dzialaj();
  return 0;
}
