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;
int n, m, k, typ[510], id[510];
int P;
vector<int> s[510];
long double mp[510][510];
template <typename T>
void chkmin(T &x, T y) {
  x = min(x, y);
}
template <typename T>
void chkmax(T &x, T y) {
  x = max(x, y);
}
template <typename T>
void read(T &x) {
  x = 0;
  int f = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  x *= f;
}
struct MAT {
  long double a[510][510];
} mat;
struct VEC {
  long double a[510];
} vec;
MAT operator*(const MAT &a, const MAT &b) {
  MAT ret;
  for (int i = 1; i <= P; ++i)
    for (int j = 1; j <= P; ++j) ret.a[i][j] = 0;
  for (int i = 1; i <= P; ++i)
    for (int t = 1; t <= P; ++t) {
      if (a.a[i][t] < 5e-8) continue;
      for (int j = 1; j <= P; ++j) {
        ret.a[i][j] += a.a[i][t] * b.a[t][j];
      }
    }
  return ret;
}
VEC operator*(const MAT &a, const VEC &b) {
  VEC ret;
  for (int i = 1; i <= P; ++i) {
    ret.a[i] = 0;
    for (int t = 1; t <= P; ++t) ret.a[i] += a.a[i][t] * b.a[t];
  }
  return ret;
}
void write() {
  puts("-------");
  for (int i = 1; i <= P; ++i)
    for (int j = 1; j <= P; ++j) printf("%.10Lf%c", mat.a[i][j], " \n"[j == P]);
}
int main() {
  read(n), read(m), read(k);
  for (int i = 1; i <= n; ++i) read(typ[i]);
  for (int i = 1; i <= m; ++i) {
    int u, v;
    read(u), read(v);
    s[u].push_back(v);
    s[v].push_back(u);
  }
  for (int i = 1; i <= n; ++i) {
    if (typ[i] == 1) {
      mat.a[i][i] = 1;
      continue;
    }
    for (unsigned j = 0, si = s[i].size(); j < si; ++j) {
      int to = s[i][j];
      mat.a[to][i] += 1.0 / si;
    }
  }
  P = n;
  for (int p = 1; p <= 15; ++p) mat = mat * mat;
  int tot = 0;
  for (int p = 1; p <= n; ++p) {
    if (!typ[p]) continue;
    id[p] = ++tot;
    for (int i = 1; i <= P; ++i) vec.a[i] = 0;
    for (unsigned j = 0, si = s[p].size(); j < si; ++j) {
      int to = s[p][j];
      vec.a[to] += 1.0 / si;
    }
    vec = mat * vec;
    for (int i = 1; i <= n; ++i) mp[p][i] = vec.a[i];
  }
  memset(vec.a, 0, sizeof(vec.a));
  vec.a[1] = 1;
  vec = mat * vec;
  static VEC tmp = vec;
  memset(vec.a, 0, sizeof(vec.a));
  for (int i = 1; i <= n; ++i)
    if (typ[i]) vec.a[id[i]] = tmp.a[i];
  memset(mat.a, 0, sizeof(mat.a));
  P = tot;
  for (int i = 1; i <= n; ++i)
    if (typ[i]) {
      for (int j = 1; j <= n; ++j)
        if (typ[j]) {
          mat.a[id[j]][id[i]] = mp[i][j];
        }
    }
  MAT ret;
  memset(ret.a, 0, sizeof(ret.a));
  for (int i = 1; i <= P; ++i) ret.a[i][i] = 1;
  k -= 2;
  while (k) {
    if (k & 1) ret = ret * mat;
    mat = mat * mat;
    k >>= 1;
  }
  vec = ret * vec;
  printf("%.10Lf\n", vec.a[id[n]]);
  return 0;
}