In the Isle of Guernsey there are n different types of coins. For each i (1 ≤ i ≤ n), coin of type i is worth ai cents. It is possible that ai = aj for some i and j (i ≠ j). 

Bessie has some set of these coins totaling t cents. She tells Jessie q pairs of integers. For each i (1 ≤ i ≤ q), the pair bi, ci tells Jessie that Bessie has a strictly greater number of coins of type bi than coins of type ci. It is known that all bi are distinct and all ci are distinct. 

Help Jessie find the number of possible combinations of coins Bessie could have. Two combinations are considered different if there is some i (1 ≤ i ≤ n), such that the number of coins Bessie has of type i is different in the two combinations. Since the answer can be very large, output it modulo 1000000007 (109 + 7). 

If there are no possible combinations of coins totaling t cents that satisfy Bessie's conditions, output 0.

Input

The first line contains three space-separated integers, n, q and t (1 ≤ n ≤ 300; 0 ≤ q ≤ n; 1 ≤ t ≤ 105). The second line contains n space separated integers, a1, a2, ..., an (1 ≤ ai ≤ 105). The next q lines each contain two distinct space-separated integers, bi and ci (1 ≤ bi, ci ≤ n; bi ≠ ci).

It's guaranteed that all bi are distinct and all ci are distinct.

Output

A single integer, the number of valid coin combinations that Bessie could have, modulo 1000000007 (109 + 7).

Examples

Input

4 2 17
3 1 2 5
4 2
3 4


Output

3


Input

3 2 6
3 1 1
1 2
2 3


Output

0


Input

3 2 10
1 2 3
1 2
2 1


Output

0

Note

For the first sample, the following 3 combinations give a total of 17 cents and satisfy the given conditions: {0 of type 1, 1 of type 2, 3 of type 3, 2 of type 4}, {0, 0, 6, 1}, {2, 0, 3, 1}.

No other combinations exist. Note that even though 4 occurs in both bi and ci,  the problem conditions are still satisfied because all bi are distinct and all ci are distinct.
#include <bits/stdc++.h>
using namespace std;
const int N = 200010;
const long long inf = 0x3f3f3f3f3f3f3f3fll;
const int mod = 1e9 + 7;
int ch[310], a[310], d[310];
bool vis[310];
int dp[2][N];
int main() {
  int n, q, t;
  scanf("%d%d%d", &n, &q, &t);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  for (int i = 0; i < q; i++) {
    int b, c;
    scanf("%d%d", &b, &c);
    ch[b] = c;
    d[c]++;
  }
  for (int i = 1; i <= n; i++) {
    if (d[i]) continue;
    int t = i;
    while (t) {
      vis[t] = 1;
      t = ch[t];
    }
  }
  for (int i = 1; i <= n; i++)
    if (!vis[i]) return puts("0"), 0;
  int x = 0;
  dp[0][0] = 1;
  for (int k = 1; k <= n; k++) {
    if (d[k]) continue;
    vector<int> vt;
    int T = k;
    while (T) {
      vt.push_back(T);
      T = ch[T];
    }
    long long p = 0;
    long long j = 0;
    for (int i = 0; i < vt.size(); i++) j += a[vt[i]], p += j, a[vt[i]] = j;
    p -= j;
    if (p > t) return puts("0"), 0;
    for (int i = 0; i <= t - p; i++) dp[x ^ 1][i + p] = dp[x][i];
    for (int i = 0; i < vt.size(); i++) {
      for (int j = 0; j <= t - a[vt[i]]; j++) {
        if (dp[x ^ 1][j])
          dp[x ^ 1][j + a[vt[i]]] =
              (dp[x ^ 1][j + a[vt[i]]] + dp[x ^ 1][j]) % mod;
      }
    }
    memset(dp[x], 0, sizeof(dp[x]));
    x ^= 1;
  }
  cout << dp[x][t] << endl;
  return 0;
}
