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 = 505, M = 105;
int n, m, K, tot, x, y, flag[N], a[N], id[N];
double f[N][N + M];
vector<int> v[N];
struct zz {
  double a[M][M];
} A;
zz cf(zz x, zz y) {
  zz z;
  memset(z.a, 0, sizeof z);
  for (int i = 1; i <= tot; i++)
    for (int j = 1; j <= tot; j++)
      for (int k = 1; k <= tot; k++) z.a[i][j] += x.a[i][k] * y.a[k][j];
  return z;
}
zz ksm(zz x, int y) {
  zz z;
  memset(z.a, 0, sizeof z.a);
  for (int i = 1; i <= tot; i++) z.a[i][i] = 1;
  for (; y; y >>= 1, x = cf(x, x))
    if (y & 1) z = cf(z, x);
  return z;
}
void gauss() {
  for (int i = 1; i <= n; i++) {
    int k = i;
    for (int j = i; j <= n; j++)
      if (fabs(f[j][i]) > fabs(f[k][i])) k = j;
    swap(f[k], f[i]);
    for (int j = i + 1; j <= n; j++) {
      double temp = f[j][i] / f[i][i];
      for (int k = i; k <= n + tot; k++) f[j][k] -= temp * f[i][k];
    }
  }
  for (int i = n; i; i--) {
    for (int j = n; j > i; j--)
      for (int k = 1; k <= tot; k++) f[i][k + n] += f[i][j] * f[j][k + n];
    for (int k = 1; k <= tot; k++) f[i][k + n] /= -f[i][i];
  }
}
int main() {
  scanf("%d%d%d", &n, &m, &K);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &flag[i]);
    if (flag[i]) a[++tot] = i, id[i] = tot;
  }
  while (m--) {
    scanf("%d%d", &x, &y);
    v[x].push_back(y);
    v[y].push_back(x);
  }
  for (int i = 1; i <= n; i++) {
    f[i][i] = -1;
    if (flag[i])
      f[i][id[i] + n] = 1;
    else
      for (int j : v[i]) f[i][j] += 1.0 / v[i].size();
  }
  gauss();
  for (int i = 1; i <= tot; i++)
    for (int j = 1; j <= tot; j++)
      for (int k : v[a[i]]) A.a[j][i] += f[k][j + n] / v[a[i]].size();
  A = ksm(A, K - 2);
  double ans = 0;
  for (int i = 1; i <= tot; i++) ans += f[1][i + n] * A.a[tot][i];
  printf("%.10lf\n", ans);
  return 0;
}