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;
struct edge {
  int to, nxxt;
} e[100102 << 1];
int n, m, k, du[100102], head[100102], cnt = 1, b[100102], rv[100102], tot;
struct node {
  double s[112][112];
  friend node operator*(node a, node b) {
    node ret;
    for (int i = 1; i <= tot; i++)
      for (int j = 1; j <= tot; j++) ret.s[i][j] = 0;
    for (int i = 1; i <= tot; i++)
      for (int j = 1; j <= tot; j++) {
        for (int ii = 1; ii <= tot; ii++)
          ret.s[i][j] += a.s[i][ii] * b.s[ii][j];
      }
    return ret;
  }
} st, md, nd;
double f[512][512], ans[512][512], tr[512][512], xs[512][512], cs[100102];
bool vis[100102];
inline void ins(int u, int v) {
  e[cnt].to = v;
  e[cnt].nxxt = head[u];
  head[u] = cnt++;
}
node ksm(node d, int tk) {
  node ret = st;
  while (tk) {
    if (tk & 1) ret = ret * d;
    d = d * d;
    tk >>= 1;
  }
  return ret;
}
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1; i <= n; i++) scanf("%d", &vis[i]);
  for (int i = 1; i <= n; i++)
    if (vis[i]) b[++tot] = i, rv[i] = tot;
  for (int i = 1; i <= m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    du[x]++, du[y]++;
    ins(x, y), ins(y, x);
  }
  for (int j = 1; j <= n; j++) {
    f[j][j] = 1;
    for (int ii = head[j]; ii; ii = e[ii].nxxt) {
      int to = e[ii].to;
      if (!vis[to]) f[j][to] -= 1.0 / du[to];
    }
  }
  for (int i = 1; i <= n; i++) xs[i][i] = 1;
  for (int i = 1; i <= n; i++) {
    int t;
    for (int j = i; j <= n; j++)
      if (fabs(f[j][i]) > 1e-6) {
        t = j;
        break;
      }
    if (t ^ i) {
      for (int j = i; j <= n; j++) swap(f[i][j], f[t][j]);
      for (int j = 1; j <= n; j++) swap(xs[i][j], xs[t][j]);
    }
    for (int j = i + 1; j <= n; j++) {
      double dv = f[j][i] / f[i][i];
      for (int ii = i; ii <= n; ii++) f[j][ii] -= dv * f[i][ii];
      for (int ii = 1; ii <= n; ii++) xs[j][ii] -= dv * xs[i][ii];
    }
  }
  for (int i = n; i; i--) {
    for (int j = 1; j <= n; j++) ans[i][j] = xs[i][j];
    for (int j = n; j > i; j--) {
      for (int ii = 1; ii <= n; ii++) ans[i][ii] -= ans[j][ii] * f[i][j];
    }
    for (int j = 1; j <= n; j++) ans[i][j] /= f[i][i];
  }
  for (int i = 1; i <= n; i++)
    if (vis[i] || i == 1) {
      memset(cs, 0, sizeof(cs));
      cs[i] = 1;
      if (vis[i]) {
        for (int j = head[i]; j; j = e[j].nxxt) {
          int to = e[j].to;
          cs[to] += 1.0 / du[i];
        }
      }
      for (int j = 1; j <= n; j++)
        if (vis[j]) {
          double sum = 0;
          for (int ii = 1; ii <= n; ii++) sum += cs[ii] * ans[j][ii];
          tr[rv[i]][rv[j]] = sum;
        }
      if (vis[i]) tr[rv[i]][rv[i]] -= 1;
    }
  for (int i = 1; i <= tot; i++)
    for (int j = 1; j <= tot; j++) md.s[i][j] = tr[i][j];
  for (int i = 1; i <= tot; i++) st.s[i][i] = 1;
  for (int i = 1; i <= tot; i++) nd.s[1][i] = tr[0][i];
  nd = nd * ksm(md, k - 2);
  printf("%.5lf\n", nd.s[1][rv[n]]);
}