#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:200000000")
using namespace std;
template <typename T>
inline T Abs(T x) {
  return (x >= 0) ? x : -x;
}
template <typename T>
inline T sqr(T x) {
  return x * x;
}
template <typename T>
string toStr(T x) {
  stringstream st;
  st << x;
  string s;
  st >> s;
  return s;
}
inline int nextInt() {
  int x;
  if (scanf("%d", &x) != 1) throw;
  return x;
}
inline long long nextInt64() {
  long long x;
  if (scanf("%I64d", &x) != 1) throw;
  return x;
}
inline double nextDouble() {
  double x;
  if (scanf("%lf", &x) != 1) throw;
  return x;
}
const int INF = (int)1E9;
const long long INF64 = (long long)1E18;
const long double EPS = 1E-9;
const long double PI = 3.1415926535897932384626433832795;
const int MAXS = 100100;
const int MOD = INF + 7;
int n, a[MAXS], q, s, d[MAXS], c[MAXS], cs = 0;
bool inE[MAXS], used[MAXS];
vector<int> g[MAXS];
void go(int v, vector<int> &p) {
  if (used[v]) {
    cout << 0 << endl;
    exit(0);
  }
  used[v] = true;
  for (int i = 0; i < (int)(g[v].size()); i++) go(g[v][i], p);
  p.push_back(v);
}
inline void update(int y, int value) {
  if (y > s) return;
  int &ans = d[y];
  ans += value;
  if (ans >= MOD) ans -= MOD;
}
int main() {
  n = nextInt();
  q = nextInt();
  s = nextInt();
  for (int i = 0; i < (int)(n); i++) a[i] = nextInt();
  for (int i = 0; i < (int)(q); i++) {
    int v = nextInt() - 1;
    int u = nextInt() - 1;
    inE[u] = true;
    g[v].push_back(u);
  }
  for (int v = 0; v < (int)(n); v++)
    if (!inE[v]) {
      vector<int> t;
      go(v, t);
      int sum = 0;
      for (int i = 0; i < (int)(t.size()); i++) sum += a[t[i]];
      for (int i = 0; i < (int)(t.size()); i++) {
        c[cs++] = sum;
        if (i != 0) s -= sum;
        sum -= a[t[i]];
        if (s < 0) {
          cout << 0 << endl;
          return 0;
        }
      }
    }
  if (s < 0 || cs != n) {
    cout << 0 << endl;
    return 0;
  }
  d[0] = 1;
  for (int i = 0; i < (int)(n); i++)
    for (int j = 0; j < (int)(s + 1); j++) update(j + c[i], d[j]);
  cout << d[s] << endl;
  cerr << clock() << endl;
  return 0;
}
