#include <bits/stdc++.h>
using namespace std;
const int M = 1000000007;
void add(int &a, int b) {
  a += b;
  if (a >= M) a -= M;
}
int n, q, t, a[350];
int to[350];
bool vis[350];
int val[350];
int dp[303][100010];
int main() {
  while (~scanf("%d %d %d", &n, &q, &t)) {
    for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
    memset(to, -1, sizeof(to));
    memset(vis, 0, sizeof(vis));
    for (int i = 1; i <= q; i++) {
      int s, e;
      scanf("%d %d", &s, &e);
      to[e] = s;
      vis[s] = 1;
    }
    bool ok = 1;
    for (int i = 1; i <= n; i++) {
      int now = i;
      val[i] = 0;
      while (1) {
        val[i] += a[now];
        now = to[now];
        if (now == i || now == -1) break;
      }
      if (now == i) ok = 0;
    }
    if (!ok) {
      puts("0");
      continue;
    } else {
      for (int i = 1; i <= n; i++)
        if (vis[i]) {
          t -= val[i];
          if (t < 0) ok = 0;
        }
      if (!ok) {
        puts("0");
        continue;
      }
      memset(dp, 0, sizeof(dp));
      dp[1][0] = 1;
      for (int i = 1; i <= n; i++)
        for (int j = 0; j <= t; j++)
          if (dp[i][j]) {
            if (i + 1 <= n) add(dp[i + 1][j], dp[i][j]);
            if (j + val[i] <= t) add(dp[i][j + val[i]], dp[i][j]);
          }
      printf("%d\n", dp[n][t]);
    }
  }
}
