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>
double a[505][505], b[505][505], res[505], f[505][505];
int n, m, k, p[505], de[505], l1[505], l2[505], d[505], tot1, tot2;
struct matrix {
  int n, m;
  double a[105][105];
  matrix(int _n, int _m) {
    n = _n;
    m = _m;
    memset(a, 0, sizeof(a));
  }
  matrix() {}
};
int gauss() {
  for (int i = 0; i < n; i++) {
    int j;
    for (j = i; j < n; j++)
      if (fabs(a[j][i]) > 1e-8) break;
    if (j == n) return false;
    if (j != i)
      for (int k = 0; k <= n; k++) {
        double t = a[j][k];
        a[j][k] = a[i][k];
        a[i][k] = t;
      }
    for (int j = i + 1; j < n; j++)
      if (fabs(a[j][i]) > 1e-8) {
        double t = a[i][i] / a[j][i];
        for (int k = i; k <= n; k++) a[j][k] = a[i][k] - a[j][k] * t;
        int k;
        for (k = i; k <= n; k++)
          if (fabs(a[j][k]) > 0) break;
        if (k == n + 1) continue;
        t = a[j][k];
        for (int l = k; l <= n; l++) a[j][l] /= t;
      }
  }
  return true;
}
void calc(int t) {
  memset(res, 0, sizeof(res));
  res[t] = 1;
  for (int i = tot2 - 1; i >= 0; i--) {
    for (int j = i + 1; j < n; j++) {
      double ans = 0;
      ans = res[j] * a[i][j];
      res[i] += -ans;
    }
    res[i] /= a[i][i];
  }
  for (int i = tot2; i < n; i++)
    for (int j = 0; j < n; j++)
      f[l1[i - tot2]][l1[t - tot2]] -= b[i][j] * res[j];
  f[0][l1[t - tot2]] = res[0];
}
matrix operator*(matrix A, matrix B) {
  matrix C;
  C.n = A.n;
  C.m = B.m;
  memset(C.a, 0, sizeof(C.a));
  for (int k = 0; k < B.n; k++)
    for (int i = 0; i < A.n; i++)
      if (fabs(A.a[i][k]) > 0)
        for (int j = 0; j < B.m; j++) C.a[i][j] += A.a[i][k] * B.a[k][j];
  return C;
}
matrix PowerMod(matrix A, int b) {
  matrix I(tot1, tot1);
  for (int i = 0; i < tot1; i++) I.a[i][i] = 1;
  while (b) {
    if (b & 1) I = I * A;
    A = A * A;
    b >>= 1;
  }
  return I;
}
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 0; i < n; i++) scanf("%d", &p[i]);
  for (int i = 0; i < n; i++) {
    if (p[i]) {
      l1[tot1] = i;
      d[i] = tot1++;
    } else {
      l2[tot2] = i;
      d[i] = tot2++;
    }
  }
  for (int i = 0; i < n; i++)
    if (p[i]) d[i] += tot2;
  for (int i = 0; i < m; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    if (u == v) printf("error!\n");
    u--, v--;
    de[d[u]]++, de[d[v]]++;
    if (!p[u])
      a[d[u]][d[v]] += -1;
    else
      b[d[u]][d[v]] += -1;
    if (!p[v])
      a[d[v]][d[u]] += -1;
    else
      b[d[v]][d[u]] += -1;
  }
  for (int i = 0; i < tot2; i++)
    for (int j = 0; j < n; j++)
      if (de[i]) a[i][j] /= de[i];
  for (int i = tot2; i < n; i++)
    for (int j = 0; j < n; j++)
      if (de[i]) b[i][j] /= de[i];
  for (int i = 0; i < n; i++) a[i][i] = 1;
  gauss();
  for (int i = tot2; i < n; i++) calc(i);
  tot1++;
  matrix A(tot1, tot1);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++)
      if (p[i] && p[j]) A.a[d[i] - tot2 + 1][d[j] - tot2 + 1] = f[i][j];
  for (int i = 1; i < n; i++)
    if (p[i]) A.a[0][d[i] - tot2 + 1] = f[0][i];
  matrix V(1, tot1);
  V.a[0][0] = 1;
  V = V * PowerMod(A, k - 1);
  printf("%.6lf\n", V.a[0][tot1 - 1]);
  return 0;
}