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, N, d, safe[511], dang[511], id[511], no[511];
vector<int> Ed[511];
double X[111], Y[111], E[111], T[511], pr[511], W[511], M[111][111],
    Q[111][111], A[511][511], B[511][511];
inline void gao(int S) {
  memset(E, 0, sizeof E);
  memset(W, 0, sizeof W);
  memset(T, 0, sizeof T);
  if (S == 1)
    T[1] = 1;
  else
    for (int v : Ed[S])
      if (id[v])
        T[id[v]] += pr[S];
      else
        E[no[v]] += pr[S];
  for (int _r = N, i = 1; i <= _r; ++i)
    for (int _r = N, k = 1; k <= _r; ++k) W[i] += B[i][k] * T[k];
  for (int _r = d, i = 1; i <= _r; ++i)
    for (int v : Ed[dang[i]])
      if (id[v]) E[i] += W[id[v]] * pr[v];
}
int main() {
  scanf("%d%d%d", &n, &m, &K);
  for (int _r = n, i = 1; i <= _r; ++i)
    if (getchar(), getchar() == 49)
      dang[no[i] = ++d] = i;
    else
      safe[id[i] = ++N] = i;
  for (int _r = m, i = 1; i <= _r; ++i) {
    int u, v;
    scanf("%d%d", &u, &v);
    Ed[u].push_back(v);
    Ed[v].push_back(u);
    ++pr[u];
    ++pr[v];
  }
  for (int _r = n, i = 1; i <= _r; ++i) pr[i] = 1 / pr[i];
  for (int _r = N, i = 1; i <= _r; ++i) {
    ++A[i][i];
    for (int v : Ed[safe[i]])
      if (id[v]) A[i][id[v]] -= pr[v];
  }
  for (int _r = N, i = 1; i <= _r; ++i) B[i][i] = 1;
  for (int _r = N, i = 1; i <= _r; ++i) {
    if (fabs(A[i][i]) < 1e-12) {
      for (int _r = N, j = i + 1; j <= _r; ++j)
        if (fabs(A[j][i]) > 1e-12) {
          for (int _r = N, k = 1; k <= _r; ++k)
            swap(A[i][k], A[j][k]), swap(B[i][k], B[j][k]);
          break;
        }
    }
    double x = 1 / A[i][i];
    for (int _r = N, j = 1; j <= _r; ++j) A[i][j] *= x, B[i][j] *= x;
    for (int _r = N, j = 1; j <= _r; ++j)
      if (i ^ j) {
        x = A[j][i];
        for (int _r = N, k = 1; k <= _r; ++k)
          A[j][k] -= A[i][k] * x, B[j][k] -= B[i][k] * x;
      }
  }
  gao(1);
  for (int _r = d, i = 1; i <= _r; ++i) X[i] = E[i];
  for (int _r = d, i = 1; i <= _r; ++i) {
    gao(dang[i]);
    for (int _r = d, j = 1; j <= _r; ++j) M[j][i] += E[j];
  }
  for (K -= 2; K; K >>= 1) {
    if (K & 1) {
      memcpy(Y, X, sizeof Y);
      memset(X, 0, sizeof X);
      for (int _r = d, i = 1; i <= _r; ++i)
        for (int _r = d, k = 1; k <= _r; ++k) X[i] += M[i][k] * Y[k];
    }
    memcpy(Q, M, sizeof Q);
    memset(M, 0, sizeof M);
    for (int _r = d, i = 1; i <= _r; ++i)
      for (int _r = d, k = 1; k <= _r; ++k)
        if (fabs(Q[i][k]) > 1e-12)
          for (int _r = d, j = 1; j <= _r; ++j) M[i][j] += Q[i][k] * Q[k][j];
  }
  printf("%.5lf\n", X[d]);
}