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, tot, m, t, du[510];
double F[510], Res[510], A[510][510 * 2], B[510][510], T[510][510], S[510];
inline void Gauss(int N) {
  for (int k = 0, i = 1; i <= N; i++, k = 0) {
    for (int j = i; j <= N; j++)
      if (fabs(A[j][i]) > fabs(A[k][i])) k = j;
    if (fabs(A[k][i]) <= 1e-10) continue;
    for (int j = 1; j <= N * 2; j++) swap(A[i][j], A[k][j]);
    double u = A[i][i];
    for (int j = 1; j <= N * 2; j++) A[i][j] /= u;
    for (int j = 1; j <= N; j++)
      if (fabs(A[j][i]) > 1e-10 && j != i) {
        double r = A[j][i] / A[i][i];
        for (k = 1; k <= N * 2; k++) A[j][k] -= A[i][k] * r;
      }
  }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) B[i][j] = A[i][j + n];
}
int q[510], ct, id[510], l[510];
struct Edge {
  int to, old;
} e[510 * 510];
inline void Lnk(int x, int y) {
  e[++ct].to = y;
  e[ct].old = l[x], l[x] = ct;
}
int main() {
  scanf("%d%d%d", &n, &m, &t);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &id[i]);
    if (id[i]) id[i] = ++tot, q[tot] = i;
  }
  if (!id[n]) t++, id[n] = ++tot, q[tot] = n;
  for (int i = 1; i <= m; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    Lnk(u, v), Lnk(v, u), du[u]++, du[v]++;
  }
  for (int i = 1; i < n; i++)
    if (!id[i])
      for (int j = l[i]; j; j = e[j].old) A[i][e[j].to] -= 1. / du[i];
  for (int i = 1; i <= n; i++) A[i][i] += 1., A[i][i + n] = 1.;
  Gauss(n);
  for (int i = 1; i <= tot; i++) Res[i] = B[1][q[i]];
  for (int i = 1; i <= tot; i++) {
    for (int j = l[q[i]]; j; j = e[j].old) {
      for (int k = 1; k <= tot; k++)
        T[i][k] += B[e[j].to][q[k]] * (1. / du[q[i]]);
    }
  }
  t -= 2;
  for (int i = 1; i <= tot; i++) A[i][i] = 1.;
  while (t) {
    if (t & 1) {
      for (int i = 1; i <= tot; i++)
        for (int j = 1; j <= tot; j++) B[i][j] = A[i][j], A[i][j] = 0.;
      for (int k = 1; k <= tot; k++)
        for (int i = 1; i <= tot; i++)
          for (int j = 1; j <= tot; j++) A[i][j] += B[i][k] * T[k][j];
    }
    for (int i = 1; i <= tot; i++)
      for (int j = 1; j <= tot; j++) B[i][j] = T[i][j], T[i][j] = 0.;
    for (int k = 1; k <= tot; k++)
      for (int i = 1; i <= tot; i++)
        for (int j = 1; j <= tot; j++) T[i][j] += B[i][k] * B[k][j];
    t /= 2;
  }
  for (int i = 1; i <= tot; i++)
    for (int j = 1; j <= tot; j++) F[i] += Res[j] * A[j][i];
  printf("%.9lf\n", F[id[n]]);
}