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 mod = 1e9 + 7;
const int maxn = 100005;
const long double eps = 1e-18;
inline int read() {
  int res, ok = 1;
  char ch;
  for (ch = getchar(); ch < '0' || ch > '9'; ch = getchar())
    if (ch == '-') ok = -1;
  res = ch - '0';
  for (ch = getchar(); ch >= '0' && ch <= '9'; ch = getchar())
    res = res * 10 + ch - '0';
  return res * ok;
}
int n, m, k, cnt, id[505], p[505], d[505];
long double w[505][1005], a[505][505], x[505][505], g[505][505];
struct matrix {
  int n;
  long double a[105][105];
  void clear() {
    memset(a, 0, sizeof(a));
    n = 0;
  }
  void print() {
    cout << n << endl;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < cnt; j++) cout << a[i][j] << " ";
      cout << endl;
    }
    cout << endl;
  }
  matrix operator*(const matrix &b) const {
    matrix c;
    c.clear();
    c.n = n;
    for (int i = 0; i < n; i++)
      for (int j = 0; j < cnt; j++)
        for (int k = 0; k < cnt; k++) c.a[i][j] += a[i][k] * b.a[k][j];
    return c;
  }
} one, st, by, ed;
inline matrix qpow(matrix a, int b) {
  matrix sum = one;
  while (b) {
    if (b & 1) sum = sum * a;
    a = a * a;
    b >>= 1;
  }
  return sum;
}
inline void gauss() {
  for (int i = 1; i <= n; i++) {
    int now = i;
    for (int j = i + 1; j <= n; j++)
      if (fabs(w[j][i]) > fabs(w[now][i])) now = j;
    if (now != i)
      for (int j = 1; j <= 2 * n; j++) swap(w[now][j], w[i][j]);
    if (fabs(w[i][i]) > eps)
      for (int j = i + 1; j <= n; j++)
        if (fabs(w[j][i]) > eps)
          for (int k = 2 * n; k >= i; k--)
            w[j][k] -= w[i][k] * w[j][i] / w[i][i];
  }
  for (int i = n; i >= 1; i--)
    if (fabs(w[i][i]) > eps) {
      for (int j = i + 1; j <= n; j++)
        for (int k = n + 1; k <= 2 * n; k++) w[i][k] -= w[i][j] * x[j][k - n];
      for (int j = n + 1; j <= 2 * n; j++) x[i][j - n] = w[i][j] / w[i][i];
    }
}
long double calc(int a, int b) {
  long double res = 0;
  for (int i = 1; i <= n; i++) res += x[a][i] * g[i][b];
  return res;
}
int main() {
  n = read();
  m = read();
  k = read();
  for (int i = 1; i <= n; i++) {
    id[i] = read();
    if (id[i] == 1) {
      cnt++;
      p[cnt] = i;
    }
  }
  for (int i = 1; i <= m; i++) {
    int u, v;
    u = read();
    v = read();
    g[u][v]++;
    g[v][u]++;
    d[u]++;
    d[v]++;
  }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) {
      if (d[i]) g[i][j] = (long double)g[i][j] / d[i];
      if (!id[j]) w[i][j] = g[i][j];
    }
  for (int i = 1; i <= n; i++) {
    w[i][i] -= 1;
    w[i][i + n] = -1;
  }
  gauss();
  one.n = by.n = cnt;
  st.n = 1;
  for (int i = 0; i < cnt; i++) one.a[i][i] = 1;
  for (int i = 0; i < cnt; i++)
    for (int j = 0; j < cnt; j++) by.a[i][j] = calc(p[i + 1], p[j + 1]);
  ed = qpow(by, k - 2);
  for (int i = 0; i < cnt; i++) st.a[0][i] = calc(1, p[i + 1]);
  st = st * ed;
  cout << st.a[0][cnt - 1] << endl;
  return 0;
}