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 = 505, M = 100500;
int read(int &n) {
  char ch = ' ';
  int q = 0, w = 1;
  for (; (ch != '-') && ((ch < '0') || (ch > '9')); ch = getchar())
    ;
  if (ch == '-') w = -1, ch = getchar();
  for (; ch >= '0' && ch <= '9'; ch = getchar()) q = q * 10 + ch - 48;
  n = q * w;
  return n;
}
int m, n, m1;
int B[M * 2][2], A[N], B0, B1[N];
int b1[N], zx[N];
double s[N][N], t[N][N], di[N][N];
void link(int q, int w) {
  B1[q]++, B1[w]++;
  B[++B0][0] = A[q];
  A[q] = B0, B[B0][1] = w;
  B[++B0][0] = A[w];
  A[w] = B0, B[B0][1] = q;
}
void chenans() {
  for (int i = 1; i <= m; i++)
    for (int j = 1; j <= m; j++) t[i][j] = 0;
  for (int k = 1; k <= m; k++)
    for (int i = 1; i <= m; i++)
      for (int j = 1; j <= m; j++) t[i][j] += s[i][k] * di[k][j];
  for (int i = 1; i <= m; i++)
    for (int j = 1; j <= m; j++) s[i][j] = t[i][j];
}
void chen() {
  for (int i = 1; i <= m; i++)
    for (int j = 1; j <= m; j++) t[i][j] = 0;
  for (int k = 1; k <= m; k++)
    for (int i = 1; i <= m; i++)
      for (int j = 1; j <= m; j++) t[i][j] += di[i][k] * di[k][j];
  for (int i = 1; i <= m; i++)
    for (int j = 1; j <= m; j++) di[i][j] = t[i][j];
}
double JC() {
  while (m1) {
    if (m1 & 1) chenans();
    chen();
    m1 >>= 1;
  }
  double ans = 0;
  for (int i = 1; i <= m; i++) ans += s[i][m];
  return ans;
}
double b[N][N], c[N][N];
int z[N];
void GS() {
  for (int i = 1; i <= n; i++) {
    b[i][i] = c[i][i] = 1;
    for (int j = A[i]; j; j = B[j][0])
      if (!zx[B[j][1]]) b[i][B[j][1]] -= 1.0 / B1[B[j][1]];
  }
  for (int i = 1; i <= n; i++) {
    int q = i;
    for (int j = i + 1; j <= n; j++)
      if (((b[j][i]) > 0 ? (b[j][i]) : -(b[j][i])) >
          ((b[q][i]) > 0 ? (b[q][i]) : -(b[q][i])))
        q = j;
    if (q != i) {
      for (int j = 1; j <= n; j++)
        swap(b[i][j], b[q][j]), swap(c[i][j], c[q][j]);
    }
    for (int j = 1; j <= n; j++)
      if (i != j) {
        double t = b[j][i] / b[i][i];
        for (int k = 1; k <= n; k++)
          b[j][k] -= t * b[i][k], c[j][k] -= t * c[i][k];
      }
  }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) c[i][j] /= b[i][i];
  for (int i = A[1]; i; i = B[i][0]) z[B[i][1]]++;
  for (int i = 1; i <= n; i++)
    if (zx[i]) {
      for (int j = 1; j <= n; j++)
        s[zx[i]][zx[i]] += c[i][j] * ((double)z[j] / B1[1]);
    }
  for (int I = 1; I <= n; I++)
    if (zx[I] && B1[I]) {
      for (int i = 1; i <= n; i++) z[i] = 0;
      for (int i = A[I]; i; i = B[i][0]) z[B[i][1]]++;
      for (int i = 1; i <= n; i++)
        if (zx[i]) {
          for (int j = 1; j <= n; j++)
            di[zx[I]][zx[i]] += c[i][j] * ((double)z[j] / B1[I]);
        }
    }
}
int main() {
  int q, w;
  read(n), read(m), read(m1);
  m1 -= 2;
  if (m1 < 0) {
    printf("0\n");
    return 0;
  }
  for (int i = 1; i <= n; i++)
    if (read(q)) b1[++b1[0]] = i, zx[i] = b1[0];
  for (int i = 1; i <= m; i++) read(q), read(w), link(q, w);
  GS();
  m = b1[0];
  printf("%.12lf\n", JC());
  return 0;
}