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 maxn = 508;
const int maxm = 108;
void inverse(int n, double A[maxn][maxn], double B[maxn][maxn]) {
  static double tmp[maxn][maxn * 2];
  memset(tmp, 0, sizeof(tmp));
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      tmp[i][j] = A[i][j];
    }
  }
  for (int i = 1; i <= n; i++) {
    tmp[i][i + n] = 1.0;
  }
  for (int i = 1; i <= n; i++) {
    int pos = -1;
    double v = 0.0;
    for (int j = i; j <= n; j++) {
      if (fabs(tmp[j][i]) > fabs(v) + 1e-9) {
        v = tmp[j][i];
        pos = j;
      }
    }
    if (pos == -1) continue;
    for (int k = 1; k <= n * 2; k++) swap(tmp[pos][k], tmp[i][k]);
    for (int k = 1; k <= n * 2; k++) tmp[i][k] /= v;
    for (int j = 1; j <= n; j++)
      if (j != i) {
        v = tmp[j][i];
        for (int k = 1; k <= n * 2; k++) {
          tmp[j][k] -= v * tmp[i][k];
        }
      }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      B[i][j] = tmp[i][n + j];
    }
  }
}
int G[maxn][maxn];
int deg[maxn];
int trap[maxn];
double P[maxn][maxn];
inline void print(int n, double A[][maxn]) {
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n + 1; j++) {
      printf("%5.2f ", A[i][j]);
    }
    printf("\n");
  }
}
double Y[maxn];
double W[maxm][maxm];
int f[maxn], invf[maxn];
inline void multi(int n, double a[maxm][maxm], double b[maxm][maxm],
                  double res[maxm][maxm]) {
  static double tmp[maxm][maxm];
  memset(tmp, 0, sizeof(tmp));
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      for (int k = 1; k <= n; k++) {
        tmp[i][j] += a[i][k] * b[k][j];
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      res[i][j] = tmp[i][j];
    }
  }
}
inline void qpow(int n, double a[maxm][maxm], int k, double res[maxm][maxm]) {
  static double tmp[maxm][maxm];
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      tmp[i][j] = 0.0;
      if (i == j) {
        tmp[i][j] = 1.0;
      }
    }
  }
  for (; k; k >>= 1) {
    if (k & 1) {
      multi(n, a, tmp, tmp);
    }
    multi(n, a, a, a);
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      res[i][j] = tmp[i][j];
    }
  }
}
int main() {
  int N, M, K;
  scanf("%d%d%d", &N, &M, &K);
  for (int i = 1; i <= N; i++) {
    scanf("%d", trap + i);
  }
  memset(G, 0, sizeof(G));
  for (int i = 0; i < M; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    G[x][y]++;
    G[y][x]++;
    deg[x]++;
    deg[y]++;
  }
  memset(P, 0, sizeof(P));
  for (int i = 1; i <= N; i++) {
    for (int j = 1; j <= N; j++) {
      if (!trap[j]) {
        P[i][j] += (double)G[i][j] / (double)deg[i];
      }
    }
  }
  for (int i = 1; i <= N; i++) {
    P[i][i] -= 1.0;
  }
  inverse(N, P, P);
  int tot = 0;
  for (int i = 1; i <= N; i++) {
    if (trap[i] || i == 1) {
      f[i] = ++tot;
      invf[f[i]] = i;
    }
  }
  for (int j = 1; j <= tot; j++) {
    int y = invf[j];
    memset(Y, 0, sizeof(Y));
    if (trap[y]) {
      for (int k = 1; k <= N; k++) {
        Y[k] = -(double)G[k][y] / (double)deg[k];
      }
    }
    for (int i = 1; i <= N; i++)
      if (trap[i] || i == 1) {
        double yi = 0.0;
        for (int k = 1; k <= N; k++) {
          yi += P[i][k] * Y[k];
        }
        W[f[i]][j] = yi;
      }
  }
  qpow(tot, W, K - 1, W);
  for (int i = 1; i <= tot; i++) {
    for (int j = 1; j <= tot; j++) {
    }
  }
  printf("%.10lf\n", W[1][tot]);
  return 0;
}