#include <bits/stdc++.h>
int n, q;
long long m;
int in[400];
int ls[400];
int mr[400];
int ch[400];
int num;
long long a[400];
long long dp[500000];
int main() {
  scanf("%d %d %I64d", &n, &q, &m);
  for (int i = 0; i < n; i++) scanf("%d", &in[i]);
  for (int i = 0; i < n; i++) {
    ls[i] = 350;
    mr[i] = 350;
  }
  for (int i = 0; i < q; i++) {
    int x, y;
    scanf("%d %d", &x, &y);
    x--;
    y--;
    ls[x] = y;
    mr[y] = x;
  }
  int chk = 1;
  for (int i = 0; i < n; i++) {
    if (ls[i] == 350) {
      int tmp = i;
      for (int j = 0; tmp != 350; j++) {
        ch[tmp] = 1;
        m -= in[tmp] * ((long long)j);
        tmp = mr[tmp];
      }
    }
    if (mr[i] == 350) {
      int tmp = i;
      long long sum = 0;
      for (; tmp != 350;) {
        sum += in[tmp];
        a[num++] = sum;
        tmp = ls[tmp];
      }
    }
  }
  for (int i = 0; i < n; i++) {
    if (ch[i] == 0) {
      chk = 0;
      break;
    }
  }
  if (m < 0) chk = 0;
  if (!chk) {
    printf("0\n");
    return 0;
  }
  dp[0] = 1;
  for (int k = 0; k < num; k++) {
    for (int i = 0; i <= m; i++) {
      dp[i + a[k]] += dp[i];
      dp[i + a[k]] %= 1000000007;
    }
  }
  printf("%I64d\n", dp[m]);
}
