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 = 510, T = 110;
int n, a, b, k;
int id[N], deg[N], ia[N], ib[N];
bool trap[N];
int g[N][N];
double mt[N][N], fp[N][N];
double bas[N], tmp[N];
int main() {
  int m;
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1; i <= n; ++i) scanf("%d", &trap[i]);
  for (int i = 1; i <= n; ++i)
    if (trap[i]) {
      id[i] = ++b;
      ib[b] = i;
    } else {
      id[i] = ++a;
      ia[a] = i;
    }
  while (m--) {
    int u, v;
    scanf("%d%d", &u, &v);
    ++g[u][v];
    ++g[v][u];
  }
  for (int i = 1; i <= n; ++i) deg[i] = accumulate(g[i] + 1, g[i] + n + 1, 0);
  for (int i = 1; i <= a; ++i)
    for (int j = 1; j <= b; ++j)
      if (g[ia[i]][ib[j]]) fp[i][j] = g[ia[i]][ib[j]] / (double)deg[ia[i]];
  for (int i = 1; i <= a; ++i)
    for (int j = 1; j <= a; ++j)
      if (g[ia[i]][ia[j]]) mt[i][j] = -g[ia[i]][ia[j]] / (double)deg[ia[i]];
  for (int i = 1; i <= a; ++i) mt[i][i] = 1;
  for (int i = 1; i <= a; ++i) {
    for (int j = 1; j <= b; ++j) fp[i][j] /= mt[i][i];
    for (int j = a; j >= i; --j) mt[i][j] /= mt[i][i];
    for (int j = i + 1; j <= a; ++j) {
      for (int t = 1; t <= b; ++t) fp[j][t] -= fp[i][t] * mt[j][i];
      for (int t = a; t >= i; --t) mt[j][t] -= mt[i][t] * mt[j][i];
    }
  }
  for (int i = a; i; --i) {
    for (int j = 1; j < i; ++j) {
      for (int t = 1; t <= b; ++t) fp[j][t] -= fp[i][t] * mt[j][i];
      for (int t = 1; t <= i; ++t) mt[j][t] -= mt[i][t] * mt[j][i];
    }
  }
  for (int i = 1; i <= b; ++i) bas[i] = fp[1][i];
  memset(mt, 0, sizeof(mt));
  for (int i = 1; i <= b; ++i) {
    int u = ib[i];
    for (int v = 1; v <= n; ++v)
      if (g[u][v]) {
        if (trap[v])
          mt[i][id[v]] += g[u][v] / (double)deg[u];
        else
          for (int j = 1; j <= b; ++j)
            mt[i][j] += fp[id[v]][j] * g[u][v] / deg[u];
      }
  }
  k -= 2;
  while (k) {
    if (k & 1) {
      memset(tmp, 0, sizeof(tmp));
      for (int i = 1; i <= b; ++i)
        for (int j = 1; j <= b; ++j) tmp[j] += bas[i] * mt[i][j];
      memcpy(bas, tmp, sizeof(tmp));
    }
    if (k >>= 1) {
      memset(fp, 0, sizeof(fp));
      for (int i = 1; i <= b; ++i)
        for (int j = 1; j <= b; ++j)
          for (int t = 1; t <= b; ++t) fp[i][j] += mt[i][t] * mt[t][j];
      memcpy(mt, fp, sizeof(mt));
    }
  }
  printf("%.6f\n", bas[b]);
  return 0;
}