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 inf = INT_MAX;
const long long INF = LLONG_MAX;
template <typename T>
inline int chkmax(T &a, T b) {
  return a < b ? a = b, 1 : 0;
}
template <typename T>
inline int chkmin(T &a, T b) {
  return a > b ? a = b, 1 : 0;
}
template <typename T>
inline T read() {
  T sum = 0, fl = 1;
  char ch = getchar();
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-') fl = -1;
  for (; isdigit(ch); ch = getchar())
    sum = (sum << 3) + (sum << 1) + (ch - '0');
  return sum * fl;
}
const int maxn = 500 + 5;
const double eps = 1e-10;
int N, M, K, Cnt;
int Trap[maxn], Edge[maxn][maxn];
struct Matrix {
  double A[maxn][maxn];
  Matrix() { memset(A, 0, sizeof A); }
  inline double *operator[](const int &first) { return A[first]; }
  inline Matrix operator*(const Matrix &rhs) {
    Matrix Ans;
    for (int i = 0; i <= Cnt; ++i)
      for (int k = 0; k <= Cnt; ++k)
        if (A[i][k] > eps)
          for (int j = 0; j <= Cnt; ++j) Ans.A[i][j] += A[i][k] * rhs.A[k][j];
    return Ans;
  }
} base[30];
inline Matrix Pow(Matrix A, int b) {
  Matrix Ans;
  for (int i = 0; i <= Cnt; ++i) Ans[i][i] = 1;
  for (; b; b >>= 1, A = A * A)
    if (b & 1) Ans = Ans * A;
  return Ans;
}
double F[maxn][maxn << 1];
inline void guass() {
  for (int i = 1, id = 1; i <= N; ++i, id = i) {
    for (int j = i; j <= N; ++j)
      if (fabs(F[j][i]) > eps) {
        id = j;
        break;
      }
    for (int j = 1; j <= N + Cnt; ++j) swap(F[i][j], F[id][j]);
    if (fabs(F[i][i]) < eps) continue;
    double tmp = F[i][i];
    for (int j = 1; j <= N + Cnt; ++j) F[i][j] /= tmp;
    for (int j = 1; j <= N; ++j)
      if (j != i && fabs(F[j][i]) > eps) {
        double tim = F[j][i];
        for (int k = 1; k <= N + Cnt; ++k) F[j][k] -= tim * F[i][k];
      }
  }
}
int Id[maxn], Pos[maxn];
inline void build_graph() {
  for (int i = 1; i <= Cnt; ++i) {
    base[0][0][i] = F[1][N + i] / F[1][1];
    for (int j = 1; j <= N; ++j)
      if (Trap[j]) base[0][Pos[j]][i] = F[j][N + i] / F[j][j];
  }
}
inline void solve() {
  for (int i = 1; i <= N; ++i)
    if (Trap[i]) Id[++Cnt] = i, Pos[i] = Cnt;
  for (int i = 1; i <= N; ++i) {
    int Deg = 0;
    F[i][i] = -1;
    for (int j = 1; j <= N; ++j) Deg += Edge[i][j];
    for (int j = 1; j <= N; ++j) {
      if (Trap[j])
        F[i][N + Pos[j]] -= Edge[i][j] * 1.0 / Deg;
      else
        F[i][j] += Edge[i][j] * 1.0 / Deg;
    }
  }
  guass();
  build_graph();
  for (int i = 1; i <= 29; ++i) base[i] = base[i - 1] * base[i - 1];
  Matrix Ans;
  K -= 1;
  for (int i = 0; i <= Cnt; ++i) Ans[i][i] = 1;
  for (int i = 29; i >= 0; --i)
    if ((K >> i) & 1) Ans = Ans * base[i];
  printf("%.10lf\n", Ans[0][Cnt]);
}
inline void input() {
  N = read<int>(), M = read<int>(), K = read<int>();
  for (int i = 1; i <= N; ++i) Trap[i] = read<int>();
  for (int i = 1; i <= M; ++i) {
    int u = read<int>(), v = read<int>();
    ++Edge[u][v];
    ++Edge[v][u];
  }
}
int main() {
  input();
  solve();
  return 0;
}