#include <bits/stdc++.h>
using namespace std;
const int Mod = 1000000007;
int main() {
  int N, M, T;
  scanf("%d%d%d", &N, &M, &T);
  static int A[300];
  for (int i = 0; i < N; i++) scanf("%d", &A[i]);
  static int Next[300];
  for (int i = 0; i < N; i++) Next[i] = -1;
  static bool In[300];
  memset(In, 0, sizeof(In));
  for (int i = 0; i < M; i++) {
    int X, Y;
    scanf("%d%d", &X, &Y);
    X--;
    Y--;
    Next[X] = Y;
    In[Y] = true;
  }
  for (int i = 0; i < N; i++) {
    int P = i;
    while (true) {
      P = Next[P];
      if (P == -1 || P == i) break;
    }
    if (P == i) {
      printf("0\n");
      return 0;
    }
  }
  static int Choice[300];
  int Total = 0;
  for (int i = 0; T >= 0 && i < N; i++)
    if (!In[i]) {
      int M = 0, P = i;
      static int Path[300];
      while (true) {
        Path[M++] = P;
        P = Next[P];
        if (P == -1) break;
      }
      for (int j = 0; T >= 0 && j < M; j++) {
        int Sum = 0;
        for (int k = 0; k <= j; k++) Sum += A[Path[k]];
        if (j < M - 1) T -= Sum;
        Choice[Total++] = Sum;
      }
    }
  if (T < 0) {
    printf("0\n");
    return 0;
  }
  static int DP[100001];
  memset(DP, 0, sizeof(DP));
  DP[0] = 1;
  for (int i = 0; i < Total; i++)
    for (int j = 0, k = Choice[i]; k <= T; j++, k++) {
      DP[k] += DP[j];
      if (DP[k] >= Mod) DP[k] -= Mod;
    }
  printf("%d\n", DP[T]);
  return 0;
}
