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, all, tot, w[613], deg[613], cn = 0, X[613 * 613], Y[613 * 613],
                                         rev[613];
double a[613][613];
struct Mat {
  double f[107][107];
  inline Mat() {
    for (int i = 1; i <= all; i++)
      for (int j = 1; j <= all; j++) f[i][j] = 0.0;
  }
  inline Mat operator*(const Mat &b) const {
    Mat p;
    int i, j, k;
    for (i = 1; i <= all; i++)
      for (k = 1; k <= all; k++)
        for (j = 1; j <= all; j++) p.f[i][k] += f[i][j] * b.f[j][k];
    return p;
  }
} tr, ans;
int main() {
  scanf("%d%d%d", &n, &m, &K);
  tot = n;
  int i, j, k, p, x, y;
  double v, iv;
  for (i = 1; i <= n; i++) {
    scanf("%d", &x);
    if (x) rev[w[i] = ++tot] = i;
  }
  for (i = 1; i <= m; i++) {
    scanf("%d%d", &x, &y);
    ++deg[x];
    ++deg[y];
    a[x][w[y] ? w[y] : y] -= 1;
    a[y][w[x] ? w[x] : x] -= 1;
  }
  for (i = 1; i <= n; i++) a[i][i] = deg[i];
  for (i = 1; i <= n; i++)
    for (j = n + 1; j <= tot; j++) a[i][j] = -a[i][j];
  for (i = 1; i <= n; i++) {
    p = i;
    for (j = i + 1; j <= n; j++)
      if (fabs(a[j][i]) > fabs(a[p][i])) p = j;
    if (p != i)
      for (k = i; k <= tot; k++) swap(a[i][k], a[p][k]);
    iv = 1.0 / a[i][i];
    for (j = i; j <= tot; j++) a[i][j] *= iv;
    for (j = i + 1; j <= n; j++)
      if (fabs(v = a[j][i]) > 0)
        for (k = i; k <= tot; k++) a[j][k] -= a[i][k] * v;
  }
  for (i = n; i >= 1 + 1; i--)
    for (j = i - 1; j >= 1; j--)
      if (fabs(v = a[j][i]) > 0) {
        a[j][i] = 0;
        for (k = n + 1; k <= tot; k++) a[j][k] -= a[i][k] * v;
      }
  for (i = n + 1; i <= tot; i++)
    for (j = n + 1; j <= tot; j++) tr.f[i - n][j - n] = a[rev[i]][j];
  all = tot - n + 1;
  for (i = n + 1; i <= tot; i++) tr.f[all][i - n] = a[1][i];
  --K;
  for (i = 1; i <= all; i++) ans.f[i][i] = 1.0;
  while (K) {
    if (K & 1) ans = ans * tr;
    K >>= 1;
    if (K) tr = tr * tr;
  }
  printf("%.8lf", ans.f[all][tot - n]);
  return 0;
}