Problem: Today DZY begins to play an old game. In this game, he is in a big maze with n rooms connected by m corridors (each corridor allows to move in both directions). You can assume that all the rooms are connected with corridors directly or indirectly.

DZY has got lost in the maze. Currently he is in the first room and has k lives. He will act like the follows:

  * Firstly he will randomly pick one of the corridors going from his current room. Each outgoing corridor has the same probability to be picked. 
  * Then he will go through the corridor and then the process repeats. 



There are some rooms which have traps in them. The first room definitely has no trap, the n-th room definitely has a trap. Each time DZY enters one of these rooms, he will lost one life. Now, DZY knows that if he enters the n-th room with exactly 2 lives, firstly he will lost one live, but then he will open a bonus round. He wants to know the probability for him to open the bonus round. Please, help him.

Input

The first line contains three integers n, m, k (2 ≤ n ≤ 500; 1 ≤ m ≤ 105; 2 ≤ k ≤ 109).

The second line contains n integers, each of them is either 0 or 1. If the i-th number is 1, then the i-th room has a trap, otherwise it has not a trap. Please note, that the number of rooms with a trap is no more than 101. It is guaranteed that the first room has no trap, and the n-th room has a trap.

Then m lines follows. Each of them contains two integers ui, vi (1 ≤ ui, vi ≤ n; ui ≠ vi), meaning that current corridor connects two rooms ui and vi. It is guaranteed that the corridor system is connected.

Output

Print the only real number — the probability for DZY to open the bonus round. The answer will be considered correct if its relative or absolute error doesn't exceed 10 - 4.

Examples

Input

5 5 3
0 0 1 0 1
1 2
2 3
3 4
4 5
1 2


Output

0.25000000


Input

3 2 2
0 1 1
1 2
2 3


Output

-0.00000000


Input

2 1 3
0 1
1 2


Output

1.00000000

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
int n, m, k, n0, n1, pos[((int)550)], ed[((int)550)][((int)550)];
long double A[((int)550)][((int)550)], dp[((int)550)][((int)550)],
    ans[1][((int)550)];
pair<bool, int> a[((int)550)];
long double ex[((int)550)][((int)550)];
void mul(long double x[((int)550)][((int)550)],
         long double y[((int)550)][((int)550)], bool pp) {
  for (int i = 0; i < 1 + (n1 - 1) * pp; i++)
    for (int j = 0; j < n1; j++) {
      ex[i][j] = 0;
      for (int k = 0; k < n1; k++) ex[i][j] += x[i][k] * y[k][j];
    }
  for (int i = 0; i < 1 + (n1 - 1) * pp; i++)
    for (int j = 0; j < n1; j++) x[i][j] = ex[i][j];
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m >> k;
  k -= 2;
  for (int i = 0; i < n; i++)
    cin >> a[i].first, a[i].second = i, n0 += (a[i].first == 0);
  sort(a, a + n);
  for (int i = 0; i < n; i++) pos[a[i].second] = i;
  for (int i = 0; i < m; i++) {
    int v, u;
    cin >> v >> u;
    v--;
    u--;
    A[pos[v]][pos[v]]--;
    A[pos[u]][pos[u]]--;
    ed[pos[v]][pos[u]]++;
    ed[pos[u]][pos[v]]++;
    if (!a[pos[v]].first) A[pos[v]][pos[u]]++;
    if (!a[pos[u]].first) A[pos[u]][pos[v]]++;
  }
  for (int i = 0; i < n0; i++) {
    for (int j = i; j < n0; j++)
      if (A[j][i]) {
        for (int k = 0; k < n; k++) swap(A[j][k], A[i][k]);
        break;
      }
    for (int j = 0; j < n0; j++) {
      if (i == j) continue;
      long double ex = A[j][i] / A[i][i];
      for (int k = 0; k < n; k++) A[j][k] -= A[i][k] * ex;
    }
  }
  for (int i = n0; i < n; i++) {
    for (int j = 0; j < n0; j++) dp[j][i] = -A[j][i] / A[j][j];
    ans[0][i - n0] = dp[0][i];
    for (int j = n0; j < n; j++) {
      int deg = 0;
      for (int k = 0; k < n; k++) {
        deg += ed[j][k];
        if (k < n0)
          dp[j][i] += dp[k][i] * ed[j][k];
        else if (k == i)
          dp[j][i] += ed[j][k];
      }
      dp[j][i] /= deg;
    }
  }
  n1 = n - n0;
  for (int i = 0; i < n1; i++)
    for (int j = 0; j < n1; j++) dp[i][j] = dp[i + n0][j + n0];
  for (int i = 0; i < 30; i++) {
    if ((k & (1 << i))) mul(ans, dp, 0);
    mul(dp, dp, 1);
  }
  for (int i = 0; i < n1; i++)
    if (a[i + n0].second == n - 1)
      return cout << fixed << setprecision(15) << ans[0][i] << "\n", 0;
  return 0;
}