#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:256000000")
using namespace std;
const int maxC = 310;
const int maxN = 101000;
const int mod = 1000000007;
int n, q, t;
int a[maxC];
int g[maxC];
int indeg[maxC];
int used[maxC];
int d[maxC][maxN];
int main() {
  scanf("%d%d%d", &n, &q, &t);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
  }
  memset(g, -1, sizeof(g));
  for (int i = 0; i < q; ++i) {
    int b, c;
    scanf("%d%d", &b, &c);
    --b, --c;
    g[b] = c;
    ++indeg[c];
  }
  int cnt = 0;
  for (int i = 0; i < n; ++i) {
    if (indeg[i] == 0) {
      int cur = i;
      vector<int> v;
      while (true) {
        v.push_back(cur);
        used[cur] = 1;
        ++cnt;
        cur = g[cur];
        if (cur == -1) {
          break;
        }
      }
      int csum = 0;
      for (int j = 0; j < v.size(); ++j) {
        csum += a[v[j]];
        a[v[j]] = csum;
        if (j + 1 != v.size()) {
          t -= a[v[j]];
          if (t < 0) {
            cout << 0 << endl;
            return 0;
          }
        }
      }
    }
  }
  if (cnt != n) {
    cout << 0 << endl;
    return 0;
  }
  d[0][0] = 1;
  for (int i = 1; i <= n; ++i) {
    int c = a[i - 1];
    for (int j = 0; j < maxN; ++j) {
      if (j - c >= 0) {
        d[i][j] += d[i][j - c];
        if (d[i][j] >= mod) {
          d[i][j] -= mod;
        }
      }
      d[i][j] += d[i - 1][j];
      if (d[i][j] >= mod) {
        d[i][j] -= mod;
      }
    }
  }
  printf("%d\n", d[n][t]);
  return 0;
}
