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>
struct Matrix {
  int n, m;
  double a[110][110];
  Matrix(int n, int m) : n(n), m(m) { memset(a, 0, sizeof(a)); }
  double *operator[](int x) { return a[x]; }
};
Matrix operator*(Matrix x, Matrix y) {
  Matrix z(x.n, y.m);
  for (int i = 1; i <= x.n; i++)
    for (int k = 1; k <= x.m; k++)
      for (int j = 1; j <= y.m; j++) z[i][j] += x[i][k] * y[k][j];
  return z;
}
Matrix ksm(Matrix x, int y) {
  Matrix z(x.n, x.n);
  for (int i = 1; i <= x.n; i++) z[i][i] = 1;
  for (; y; y >>= 1, x = x * x)
    if (y & 1) z = x * z;
  return z;
}
int n, m, K, deg[510], a[110], typ[510];
double A[510][510 + 110];
std::vector<int> to[510];
int main() {
  scanf("%d%d%d", &n, &m, &K);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &typ[i]);
    if (typ[i]) a[++a[0]] = i;
  }
  for (int i = 1, x, y; i <= m; i++) {
    scanf("%d%d", &x, &y);
    deg[x]++, deg[y]++;
    to[x].push_back(y), to[y].push_back(x);
  }
  for (int i = 1; i <= n; i++) {
    if (!typ[i]) {
      for (auto j : to[i]) A[i][j] += 1.0 / deg[i];
      A[i][i] = -1;
    } else {
      A[i][i] = 1;
      for (int j = 1; j <= a[0]; j++)
        if (a[j] == i) A[i][n + j] = 1;
    }
  }
  int lim = a[0] + n;
  double t;
  for (int i = 1; i <= n; i++) {
    t = A[i][i];
    for (int j = 1; j <= lim; j++) A[i][j] /= t;
    for (int j = i + 1; j <= n; j++) {
      t = A[j][i] / A[i][i];
      for (int k = 1; k <= lim; k++) A[j][k] -= A[i][k] * t;
    }
  }
  for (int i = n; i; i--)
    for (int j = i - 1; j; j--)
      for (int k = n + 1; k <= lim; k++) A[j][k] -= A[j][i] * A[i][k];
  Matrix x(1, a[0]), y(a[0], a[0]);
  for (int i = 1; i <= a[0]; i++) x[1][i] = A[1][n + i];
  for (int i = 1; i <= a[0]; i++)
    for (int j = 1; j <= a[0]; j++) {
      for (auto k : to[a[i]]) y[i][j] += A[k][n + j];
      y[i][j] /= deg[a[i]];
    }
  x = x * ksm(y, K - 2);
  printf("%.6lf\n", x[1][a[0]]);
  return 0;
}