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;
int T[505];
vector<int> V;
int mat[501][501];
int inin[501];
double eqmat[501][1010];
const int MAT = 101;
double G[MAT][MAT], G2[MAT][MAT];
void powmat(signed long long p, int n, double a[MAT][MAT], double r[MAT][MAT]) {
  int i, x, y, z;
  static double a2[MAT][MAT];
  for (x = 0; x < n; x++)
    for (y = 0; y < n; y++) a2[x][y] = a[x][y];
  for (x = 0; x < n; x++)
    for (y = 0; y < n; y++) r[x][y] = 0;
  for (i = 0; i < n; i++) r[i][i] = 1;
  while (p) {
    double h[MAT][MAT];
    if (p % 2) {
      for (x = 0; x < n; x++)
        for (y = 0; y < n; y++) h[x][y] = 0;
      for (x = 0; x < n; x++)
        for (z = 0; z < n; z++)
          for (y = 0; y < n; y++) h[x][y] += r[x][z] * a2[z][y];
      for (x = 0; x < n; x++)
        for (y = 0; y < n; y++) r[x][y] = h[x][y];
    }
    for (x = 0; x < n; x++)
      for (y = 0; y < n; y++) h[x][y] = 0;
    for (x = 0; x < n; x++)
      for (z = 0; z < n; z++)
        for (y = 0; y < n; y++) h[x][y] += a2[x][z] * a2[z][y];
    for (x = 0; x < n; x++)
      for (y = 0; y < n; y++) a2[x][y] = h[x][y];
    p >>= 1;
  }
}
void solve() {
  int i, j, k, l, r, x, y;
  string s;
  cin >> N >> M >> K;
  for (i = 0; i < N; i++) cin >> T[i];
  for (i = 0; i < M; i++) {
    cin >> x >> y;
    inin[x - 1]++;
    inin[y - 1]++;
    mat[x - 1][y - 1]++;
    mat[y - 1][x - 1]++;
  }
  for (i = 0; i < N; i++) {
    if (i == 0 || T[i]) V.push_back(i);
    eqmat[i][i]--;
    for (j = 0; j < N; j++) {
      if (T[i] == 0) eqmat[j][i] += mat[i][j] * 1.0 / inin[i];
      eqmat[j][i + N] += mat[i][j] * 1.0 / inin[i];
    }
  }
  for (i = 0; i < N; i++) {
    for (x = 2 * N - 1; x >= i; x--) eqmat[i][x] /= eqmat[i][i];
    for (j = 0; j < N; j++)
      if (j != i && eqmat[j][i]) {
        double rate = eqmat[j][i] / eqmat[i][i];
        for (x = 0; x < 2 * N; x++) eqmat[j][x] -= rate * eqmat[i][x];
      }
  }
  for (i = 0; i < N; i++) {
    double tot = 0;
    for (j = 0; j < N; j++)
      if (T[j] == 0) eqmat[j][i + N] = 0;
    for (j = 0; j < N; j++)
      if (T[j]) tot += eqmat[j][i + N];
    for (j = 0; j < N; j++)
      if (T[j]) eqmat[j][i + N] /= tot;
  }
  for (i = 0; i < V.size(); i++)
    for (j = 0; j < V.size(); j++) G[i][j] = eqmat[V[j]][N + V[i]];
  powmat(K - 1, V.size(), G, G2);
  (void)printf("%.12lf\n", G2[0][V.size() - 1]);
}
int main(int argc, char** argv) {
  string s;
  int i;
  if (argc == 1) ios::sync_with_stdio(false);
  for (i = 0; i < argc - 1; i++) s += argv[i + 1], s += '\n';
  for (i = 0; i < s.size(); i++) ungetc(s[s.size() - 1 - i], stdin);
  solve();
  return 0;
}