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>
const int N = 510;
const int NN = 110;
using namespace std;
int read() {
  int x = 0, f = 1, c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
  return x * f;
}
struct matrix {
  double num[NN][NN];
} ans, tmp, opt;
double p[N][N], mat[N][N << 1], cnt[N], b[N], res;
int g[N][N], f[N], id[N], n, m, x, y, k, sum, deg[N];
void Gauss() {
  for (int i = 1; i <= n; i++) mat[i][i + n] = 1;
  for (int i = 1; i <= n; i++) {
    for (int j = i; j <= n; j++)
      if (mat[j][i]) {
        for (int k = n * 2; k >= i; k--) swap(mat[i][k], mat[j][k]);
        break;
      }
    for (int k = n * 2; k >= i; k--) mat[i][k] /= mat[i][i];
    for (int j = 1; j <= n; j++)
      if (j != i) {
        for (int k = n * 2; k >= i; k--) mat[j][k] -= mat[j][i] * mat[i][k];
      }
  }
}
void mul(matrix &C, matrix A, matrix B) {
  for (int i = 1; i <= sum; i++)
    for (int j = 1; j <= sum; j++) {
      tmp.num[i][j] = 0;
      for (int k = 1; k <= sum; k++) tmp.num[i][j] += A.num[i][k] * B.num[k][j];
    }
  for (int i = 1; i <= sum; i++)
    for (int j = 1; j <= sum; j++) C.num[i][j] = tmp.num[i][j];
}
int main() {
  n = read();
  m = read();
  k = read();
  for (int i = 1; i <= n; i++) {
    f[i] = read();
    if (f[i]) id[i] = ++sum;
  }
  for (int i = 1; i <= m; i++) {
    x = read();
    y = read();
    g[x][y]++;
    g[y][x]++;
    deg[x]++;
    deg[y]++;
  }
  for (int i = 1; i <= n; i++) mat[i][i] += 1;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++)
      if (!f[j]) mat[i][j] -= 1.0 / deg[j] * g[j][i];
  Gauss();
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) cnt[j] = 1. / deg[i] * g[i][j];
    for (int u = 1; u <= n; u++) {
      b[u] = 0;
      for (int v = 1; v <= n; v++)
        if (!f[v]) b[u] += 1. / deg[v] * cnt[v] * g[v][u];
    }
    for (int x = 1; x <= n; x++) {
      p[i][x] = cnt[x];
      for (int y = 1; y <= n; y++) p[i][x] += mat[x][y + n] * b[y];
    }
  }
  for (int i = 1; i <= n; i++)
    if (f[i]) ans.num[id[i]][id[i]] = p[1][i];
  for (int i = 1; i <= n; i++)
    if (f[i])
      for (int j = 1; j <= n; j++)
        if (f[j]) opt.num[id[i]][id[j]] = p[i][j];
  for (k -= 2; k; k >>= 1, mul(opt, opt, opt))
    if (k & 1) mul(ans, ans, opt);
  for (int i = 1; i <= sum; i++) res += ans.num[i][id[n]];
  printf("%.12lf", res);
}