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 MAX_SIZE = 500;
int n;
int trap[110], tn, isTrap[MAX_SIZE + 10];
double mat[MAX_SIZE + 10][MAX_SIZE * 2 + 10];
int A[100010], B[100010], m;
int deg[MAX_SIZE + 10];
int step;
void elim() {
  for (int i = 0; i < n; i++) {
    int minn = i;
    for (int j = i + 1; j < n; j++)
      if (fabs(mat[j][i]) > fabs(mat[minn][i])) minn = j;
    if (minn != i)
      for (int j = i; j < (n << 1); j++) swap(mat[i][j], mat[minn][j]);
    for (int j = i + 1; j < n; j++) {
      double x = mat[j][i] / mat[i][i];
      for (int k = i; k < (n << 1); k++) mat[j][k] -= mat[i][k] * x;
    }
  }
  for (int i = n - 1; i >= 0; i--) {
    for (int j = 0; j < n; j++) mat[i][n + j] /= mat[i][i];
    for (int j = i - 1; j >= 0; j--)
      for (int k = 0; k < n; k++) mat[j][n + k] -= mat[i][n + k] * mat[j][i];
  }
}
struct Matrix {
  double mat[110][110];
  int h, w;
};
Matrix operator*(const Matrix& a, const Matrix& b) {
  Matrix ans;
  ans.h = a.h;
  ans.w = b.w;
  for (int i = 0; i < ans.h; i++)
    for (int j = 0; j < ans.w; j++) {
      ans.mat[i][j] = 0.0;
      for (int k = 0; k < b.h; k++) ans.mat[i][j] += a.mat[i][k] * b.mat[k][j];
    }
  return ans;
}
Matrix st, cg;
Matrix fastPow(const Matrix& b, int p) {
  Matrix cur = b, ans;
  memset(ans.mat, 0, sizeof(ans.mat));
  ans.h = ans.w = b.h;
  for (int i = 0; i < ans.h; i++) ans.mat[i][i] = 1.0;
  while (p) {
    if (p & 1) ans = ans * cur;
    p >>= 1;
    cur = cur * cur;
  }
  return ans;
}
int main() {
  scanf("%d%d%d", &n, &m, &step);
  for (int i = 0; i < n; i++) {
    int v;
    scanf("%d", &v);
    isTrap[i] = v;
    if (v) trap[tn++] = i;
  }
  for (int i = 0; i < m; i++) {
    scanf("%d%d", A + i, B + i);
    --A[i];
    --B[i];
    ++deg[A[i]];
    ++deg[B[i]];
  }
  for (int i = 0; i < n; i++) mat[i][i] = 1.0;
  for (int i = 0; i < m; i++) {
    if (isTrap[A[i]])
      mat[B[i]][n + A[i]] += 1.0 / deg[A[i]];
    else
      mat[B[i]][A[i]] -= 1.0 / deg[A[i]];
    if (isTrap[B[i]])
      mat[A[i]][n + B[i]] += 1.0 / deg[B[i]];
    else
      mat[A[i]][B[i]] -= 1.0 / deg[B[i]];
  }
  for (int i = 0; i < n; i++)
    if (!isTrap[i]) mat[i][n + i] = 1.0;
  elim();
  st.h = tn;
  st.w = 1;
  for (int i = 0; i < tn; i++) st.mat[i][0] = mat[trap[i]][n];
  cg.h = cg.w = tn;
  for (int i = 0; i < tn; i++)
    for (int j = 0; j < tn; j++) cg.mat[i][j] = mat[trap[i]][n + trap[j]];
  st = fastPow(cg, step - 2) * st;
  printf("%.10f\n", st.mat[tn - 1][0]);
  return 0;
}