#include <bits/stdc++.h>
using namespace std;
const int MAXN = 310;
const int MAXT = 100100;
const int MOD = 1000000007;
int a[MAXN], ojc[MAXN], syn[MAXN];
int n, q, t;
vector<int> num;
int res[MAXT];
bool czy[MAXN];
void readData() {
  scanf("%d%d%d", &n, &q, &t);
  for (int i = 1; i <= (n); ++i) {
    scanf("%d", a + i);
  }
  int b, c;
  for (int i = 0; i < (q); ++i) {
    scanf("%d%d", &b, &c);
    ojc[c] = b;
    syn[b] = c;
  }
}
void sprawdz(int v) {
  if (syn[v] != 0) return;
  vector<int> nr;
  while (v != 0) {
    nr.push_back(a[v]);
    czy[v] = true;
    v = ojc[v];
  }
  vector<int> toad;
  for (int i = 0; i < ((int)nr.size()); ++i) {
    int obe = 0;
    for (int j = i; j <= ((int)nr.size() - 1); ++j) {
      obe += nr[j];
    }
    toad.push_back(obe);
  }
  for (int j = 1; j <= ((int)toad.size() - 1); ++j) {
    t -= toad[j];
    if (t < 0) {
      printf("0\n");
      exit(0);
    }
  }
  for (int i = 0; i < ((int)toad.size()); ++i) {
    num.push_back(toad[i]);
  }
}
void policz() {
  int obe;
  int tmp[MAXT];
  res[0] = 1;
  for (int i = 0; i < ((int)num.size()); ++i) {
    obe = num[i];
    memset(tmp, 0, sizeof(tmp));
    for (int j = 0; j < (t + 1); ++j) {
      if (j >= obe) {
        tmp[j] = tmp[j - obe] + res[j];
        tmp[j] %= MOD;
      } else {
        tmp[j] = res[j];
      }
    }
    for (int j = 0; j < (t + 1); ++j) {
      res[j] = tmp[j];
    }
  }
}
int main() {
  readData();
  for (int i = 1; i <= (n); ++i) {
    if (!czy[i]) sprawdz(i);
  }
  for (int i = 1; i <= (n); ++i) {
    if (!czy[i]) {
      printf("0\n");
      return 0;
    }
  }
  if (t < 0) {
    printf("0\n");
    return 0;
  }
  policz();
  printf("%d\n", res[t] % MOD);
}
