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 N = 666;
const double eps = 1e-10;
int n, m, K, cnt, sz;
int id[N], nod[N], cur[N];
double deg[N], g[N][N];
bool trap[N];
double v[N][N];
struct node {
  double vec[N];
} vv[N];
struct mat {
  double v[166][166];
  mat() { memset(v, 0, sizeof(v)); }
} ans;
node operator*(node a, double w) {
  for (int i = 0; i <= n; i++) a.vec[i] *= w;
  return a;
}
node operator/(node a, double w) {
  for (int i = 0; i <= n; i++) a.vec[i] /= w;
  return a;
}
node operator+(node a, node b) {
  for (int i = 0; i <= n; i++) a.vec[i] += b.vec[i];
  return a;
}
node operator-(node a, node b) {
  for (int i = 0; i <= n; i++) a.vec[i] -= b.vec[i];
  return a;
}
mat operator*(mat a, mat b) {
  mat t;
  memset(t.v, 0, sizeof(t.v));
  for (int i = 0; i <= sz; i++) {
    for (int j = 0; j <= sz; j++) {
      for (int k = 0; k <= sz; k++) {
        t.v[i][j] += a.v[i][k] * b.v[k][j];
      }
    }
  }
  return t;
}
int main() {
  cin >> n >> m >> K;
  for (int i = 1; i <= n; i++) scanf("%d", &trap[i]);
  for (int i = 1; i <= m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    ++deg[x], ++deg[y], ++g[x][y], ++g[y][x];
  }
  for (int i = 1; i <= n; i++) {
    if (trap[i]) {
      nod[++cnt] = i, id[i] = cnt;
    }
  }
  sz = cnt;
  for (int i = 1; i <= n; i++) {
    v[i][i] = -1;
    for (int j = 1; j <= n; j++) {
      if (trap[j]) {
        v[i][id[j] + n] += 1.0 * g[i][j] / deg[i];
      } else {
        v[i][j] += 1.0 * g[i][j] / deg[i];
      }
    }
  }
  for (int i = 1; i <= sz; i++) {
    vv[i + n].vec[i] = 1;
    v[i + n][i + n] = 1;
  }
  for (int i = 1; i <= n + sz; i++) {
    int me = -1;
    double mx = 0;
    for (int j = 1; j <= n + sz; j++) {
      if (abs(v[i][j]) > mx) {
        mx = abs(v[i][j]);
        me = j;
      }
    }
    if (me == -1 || abs(mx) < eps) continue;
    cur[i] = me;
    double val = v[i][me];
    for (int j = 1; j <= n + sz; j++) v[i][j] /= val;
    vv[i] = vv[i] / val;
    for (int j = 1; j <= n + sz; j++) {
      if (j != i && abs(v[j][me]) > eps) {
        double val = v[j][me];
        for (int k = 1; k <= n + sz; k++) v[j][k] -= v[i][k] * val;
        vv[j] = vv[j] - vv[i] * val;
      }
    }
  }
  for (int i = 1; i <= n + sz; i++) {
    if ((cur[i] <= n && trap[cur[i]]) || cur[i] == 1) {
      if (cur[i] == 1) {
        for (int j = 1; j <= sz; j++) ans.v[0][j] = vv[i].vec[j];
      } else {
        for (int j = 1; j <= sz; j++) ans.v[id[cur[i]]][j] = vv[i].vec[j];
      }
    }
  }
  mat res;
  memset(res.v, 0, sizeof(res.v));
  for (int i = 0; i <= sz; i++) res.v[i][i] = 1;
  int nn = K - 1;
  for (; nn; nn >>= 1) {
    if (nn & 1) res = res * ans;
    ans = ans * ans;
  }
  printf("%.10lf\n", res.v[0][id[n]]);
  return 0;
}