#include <bits/stdc++.h>
using namespace std;
int flag = 1, n, q, t;
int f[100010];
typedef struct node {
  int val, from, to, vis;
} NODE;
NODE point[310];
void dfs(int x) {
  point[x].vis = 1;
  if (point[x].to == 0) return;
  point[point[x].to].val += point[x].val;
  dfs(point[x].to);
  t -= point[x].val;
  if (t < 0) flag = 0;
}
int main() {
  int x, y;
  scanf("%d %d %d", &n, &q, &t);
  memset(f, 0, sizeof(f));
  f[0] = 1;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &point[i].val);
    point[i].from = point[i].to = point[i].vis = 0;
  }
  for (int i = 0; i < q; i++) {
    scanf("%d %d", &x, &y);
    point[x].to = y;
    point[y].from = x;
  }
  for (int i = 1; i <= n; i++)
    if (point[i].from == 0) dfs(i);
  if (flag == 0) {
    printf("0\n");
    return 0;
  }
  for (int i = 1; i <= n; i++)
    if (point[i].vis == 0) {
      printf("0\n");
      return 0;
    }
  for (int i = 1; i <= n; i++)
    for (int j = 0; j + point[i].val <= t; j++) {
      int tar = j + point[i].val;
      int ftar = f[tar];
      f[tar] = (f[tar] + f[j]) % 1000000007;
    }
  printf("%d\n", f[t]);
  return 0;
}
