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 = 0x20202020;
const long long mod = 1000000009;
const double eps = 1e-9;
const double pi = 3.1415926535897932384626;
const int DX[] = {1, 0, -1, 0}, DY[] = {0, 1, 0, -1};
long long powmod(long long a, long long b) {
  long long res = 1;
  a %= mod;
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % mod;
    a = a * a % mod;
  }
  return res;
}
long long powmod(long long a, long long b, long long mod) {
  long long res = 1;
  a %= mod;
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % mod;
    a = a * a % mod;
  }
  return res;
}
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
const int N = 510;
int n, m, l, x, y;
int g[N][N], d[N], tp[N];
double mat[N][2 * N], res[N][N], base[N][N], tmp[N][N], p[N][N];
double b[N];
vector<int> vep;
int main() {
  scanf("%d%d%d", &n, &m, &l);
  l -= 2;
  for (int i = 0; i < (int)n; i++) scanf("%d", tp + i);
  for (int i = 0; i < (int)m; i++) {
    scanf("%d%d", &x, &y);
    --x;
    --y;
    g[x][y]++;
    g[y][x]++;
    d[x]++;
    d[y]++;
  }
  for (int i = 0; i < (int)n; i++)
    for (int j = 0; j < (int)n; j++)
      if (i == j)
        mat[i][j] = 1;
      else if (!tp[j])
        mat[i][j] = -1. * g[i][j] / d[j];
  for (int i = 0; i < (int)n; i++) mat[i][i + n] = 1;
  for (int i = 0; i < (int)n; i++) {
    double coff = mat[i][i];
    for (int j = 0; j < (int)2 * n; j++) mat[i][j] /= coff;
    for (int j = 0; j < (int)n; j++)
      if (j != i) {
        coff = -mat[j][i];
        for (int k = 0; k < (int)2 * n; k++) mat[j][k] += coff * mat[i][k];
      }
  }
  for (int i = 0; i < (int)n; i++) {
    for (int j = 0; j < (int)n; j++) b[j] = 1. * g[i][j] / d[i];
    for (int j = 0; j < (int)n; j++)
      for (int k = 0; k < (int)n; k++) p[i][j] += mat[j][k + n] * b[k];
  }
  for (int i = 0; i < (int)n; i++)
    if (tp[i]) vep.push_back(i);
  m = ((int)(vep).size());
  for (int i = 0; i < (int)m; i++)
    for (int j = 0; j < (int)m; j++) base[i][j] = p[vep[i]][vep[j]];
  for (int i = 0; i < (int)m; i++) res[i][i] = 1;
  for (; l; l >>= 1) {
    if (l & 1) {
      for (int i = 0; i < (int)m; i++)
        for (int j = 0; j < (int)m; j++) {
          tmp[i][j] = 0;
          for (int k = 0; k < (int)m; k++) tmp[i][j] += res[i][k] * base[k][j];
        }
      for (int i = 0; i < (int)m; i++)
        for (int j = 0; j < (int)m; j++) res[i][j] = tmp[i][j];
    }
    for (int i = 0; i < (int)m; i++)
      for (int j = 0; j < (int)m; j++) {
        tmp[i][j] = 0;
        for (int k = 0; k < (int)m; k++) tmp[i][j] += base[i][k] * base[k][j];
      }
    for (int i = 0; i < (int)m; i++)
      for (int j = 0; j < (int)m; j++) base[i][j] = tmp[i][j];
  }
  double ans = 0;
  for (int i = 0; i < (int)m; i++) ans += p[0][vep[i]] * res[i][m - 1];
  printf("%.10f\n", ans);
}