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 long long mo = 1e9 + 7;
template <typename _T>
void read(_T &x) {
  _T f = 1;
  x = 0;
  char s = getchar();
  while (s > '9' || s < '0') {
    if (s == '-') f = -1;
    s = getchar();
  }
  while (s >= '0' && s <= '9') {
    x = (x << 3) + (x << 1) + (s ^ 48);
    s = getchar();
  }
  x *= f;
}
template <typename _T>
_T Fabs(_T x) {
  return x < 0 ? -x : x;
}
int n, m, t, mem[605], num, id[605];
int deg[605], con[605][605];
bool xj[605];
double dp[605][605], p[605][605];
void guass(int opt, int c) {
  for (int i = 1; i <= n; i++) {
    int id = i;
    for (int j = i + 1; j <= n; j++)
      if (Fabs(dp[j][i]) > Fabs(dp[id][i])) id = j;
    if (id != i)
      for (int j = i; j <= n + c; j++) swap(dp[i][j], dp[id][j]);
    for (int j = i + 1; j <= n; j++)
      if (Fabs(dp[j][i]) > 0) {
        double lp = dp[j][i] / dp[i][i];
        for (int k = i; k <= n + c; k++) dp[j][k] -= dp[i][k] * lp;
      }
  }
  if (opt ^ 1) {
    for (int i = n; i > 0; i--) {
      for (int j = i + 1; j <= n; j++)
        if (Fabs(dp[i][j]) > 0)
          for (int k = n + 1; k <= n + c; k++)
            dp[i][k] -= dp[i][j] * p[k - n][j];
      for (int k = n + 1; k <= n + c; k++) p[k - n][i] = dp[i][k] / dp[i][i];
    }
  } else {
    for (int i = n; i > 0; i--) {
      for (int j = i + 1; j <= n; j++)
        if (Fabs(dp[i][j]) > 0) dp[i][n + 1] -= dp[i][j] * p[0][j];
      p[0][i] = dp[i][n + 1] / dp[i][i];
    }
  }
}
struct tree {
  double a[105][105];
  tree() { memset(a, 0, sizeof(a)); }
  void init() {
    for (int i = 0; i <= num; i++) a[i][i] = 1.0;
  }
  tree friend operator*(const tree &a, const tree &b) {
    tree c;
    for (int k = 0; k <= num; k++)
      for (int i = 0; i <= num; i++)
        for (int j = 0; j <= num; j++) c.a[i][j] += a.a[i][k] * b.a[k][j];
    return c;
  }
} S, B;
tree qkpow(tree A, int s) {
  tree T;
  T.init();
  while (s) {
    if (s & 1) T = T * A;
    A = A * A;
    s >>= 1;
  }
  return T;
}
signed main() {
  read(n);
  read(m);
  read(t);
  for (int i = 1; i <= n; i++) {
    read(xj[i]);
    if (xj[i]) mem[++num] = i, id[i] = num;
  }
  for (int i = 1; i <= m; i++) {
    int x, y;
    read(x);
    read(y);
    deg[x]++;
    deg[y]++;
    ++con[x][y];
    ++con[y][x];
  }
  for (int i = 1; i <= n; i++) {
    dp[i][i] = 1.0;
    for (int j = 1; j <= n; j++) {
      if (j == i) continue;
      if (!xj[j] && con[i][j]) dp[i][j] = -1.0 * con[i][j] / deg[j];
    }
    if (i == 1) dp[i][n + 1] = 1.0;
  }
  guass(1, 1);
  memset(dp, 0, sizeof(dp));
  for (int i = 1; i <= n; i++) {
    dp[i][i] = 1.0;
    for (int j = 1; j <= n; j++) {
      if (j == i) continue;
      if (!xj[j] && con[i][j]) dp[i][j] = -1.0 * con[i][j] / deg[j];
    }
    for (int j = 1; j <= num; j++) {
      if (mem[j] == i) continue;
      if (con[mem[j]][i]) dp[i][j + n] = 1.0 * con[mem[j]][i] / deg[mem[j]];
    }
  }
  guass(0, num);
  for (int j = 1; j <= num; j++) B.a[0][j] = p[0][mem[j]];
  for (int i = 1; i <= num; i++)
    for (int j = 1; j <= num; j++) B.a[i][j] = p[i][mem[j]];
  S.a[0][0] = 1.0;
  S = S * qkpow(B, t - 1);
  printf("%.10lf", S.a[0][num]);
  return 0;
}