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;
const int N = 600, M = 100500;
int read(int &n) {
  char ch = ' ';
  int q = 0, w = 1;
  for (; (ch != '-') && ((ch < '0') || (ch > '9')); ch = getchar())
    ;
  if (ch == '-') w = -1, ch = getchar();
  for (; ch >= '0' && ch <= '9'; ch = getchar()) q = q * 10 + ch - 48;
  n = q * w;
  return n;
}
int m, n, m1;
int B[M * 2][2], A[N], B0, Ha[N], B1[N];
int b[N], zx[N], g[N];
int b1[N][N];
bool z[N];
double d[N][N], s[N][N], t[N][N], f[N][N];
double ans;
void link(int q, int w) {
  B1[q]++, B1[w]++;
  B[++B0][0] = A[q];
  if (!A[q]) Ha[q] = B0;
  A[q] = B0, B[B0][1] = w;
  B[++B0][0] = A[w];
  if (!A[w]) Ha[w] = B0;
  A[w] = B0, B[B0][1] = q;
}
void dfs(int q, double p, int I) {
  if (zx[q] && zx[q] != I) return;
  z[q] = 1;
  for (int i = A[q]; i; i = B[i][0]) {
    if (zx[B[i][1]]) d[I][zx[B[i][1]]] += p * (1.0 * b1[q][B[i][1]] / B1[q]);
    if (!z[B[i][1]]) dfs(B[i][1], p * (1.0 * b1[q][B[i][1]] / B1[q]), I);
  }
  z[q] = 0;
}
void chenans() {
  for (int i = 1; i <= m; i++)
    for (int j = 1; j <= m; j++) t[i][j] = 0;
  for (int k = 1; k <= m; k++)
    for (int i = 1; i <= m; i++)
      for (int j = 1; j <= m; j++) t[i][j] += s[i][k] * d[k][j];
  for (int i = 1; i <= m; i++)
    for (int j = 1; j <= m; j++) s[i][j] = t[i][j];
}
void chen() {
  for (int i = 1; i <= m; i++)
    for (int j = 1; j <= m; j++) t[i][j] = 0;
  for (int k = 1; k <= m; k++)
    for (int i = 1; i <= m; i++)
      for (int j = 1; j <= m; j++) t[i][j] += d[i][k] * d[k][j];
  for (int i = 1; i <= m; i++)
    for (int j = 1; j <= m; j++) d[i][j] = t[i][j];
}
int main() {
  int q, w;
  read(n), read(m), read(m1);
  m1 -= 2;
  if (m1 < 0) {
    printf("0\n");
    return 0;
  }
  for (int i = 1; i <= n; i++)
    if (read(q)) b[++b[0]] = i, zx[i] = b[0];
  for (int i = 1; i <= m; i++) read(q), read(w), link(q, w);
  for (int i = 1; i <= n; i++) g[i] = i;
  for (int i = 1; i <= n; i++)
    if (!zx[i] && g[i] == i) {
      for (int j = A[i]; j; j = B[j][0])
        if (!zx[B[j][1]] && g[B[j][1]] == B[j][1] && B[j][1] != i) {
          B[Ha[i]][0] = A[B[j][1]], Ha[i] = Ha[B[j][1]];
          g[B[j][1]] = i;
          B1[i] += B1[B[j][1]];
        }
    }
  for (int i = 1; i <= n; i++)
    if (zx[i] || i == g[i]) {
      for (int j = A[i], j1 = 0; j; j = B[j][0]) {
        w = B[j][1] = g[B[j][1]];
        if (b1[i][w] || g[w] == g[i]) {
          if (j1)
            B[j1][0] = B[j][0];
          else
            A[i] = B[j][0];
        } else
          j1 = j;
        if (g[w] == g[i])
          B1[i]--;
        else
          b1[i][w]++;
      }
    }
  m = b[0];
  dfs(g[1], 1, 0);
  for (int i = 1; i <= m; i++) s[i][i] = d[0][i];
  for (int i = 1; i <= m; i++) {
    dfs(b[i], 1, i);
  }
  while (m1) {
    if (m1 & 1) chenans();
    chen();
    m1 >>= 1;
  }
  ans = 0;
  for (int i = 1; i <= m; i++)
    if (d[0][i] > 0) ans += s[i][m];
  printf("%.12lf\n", ans);
  return 0;
}