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;
long n, k, m, bad[1000];
double temp[501][501], temp1[501][501];
double g[501][501], deg[501];
double prob[501][501], p1[501][501];
long a, b;
double ans[501];
long ind[600];
long calc;
double answ;
void mult(double v[501][501], long n) {
  double temp[501][501], temp1[501][501];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++)
      temp[i][j] = v[i][j], temp1[j][i] = v[i][j], v[i][j] = 0;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++)
      for (int k = 0; k < n; k++) v[i][j] += temp[i][k] * temp1[j][k];
}
void solve(double a[501][501], double b[501], long pw, long n) {
  double temp[1000];
  while (pw > 0) {
    if (pw & 1) {
      for (int i = 0; i < n; i++) temp[i] = 0;
      for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++) temp[j] += b[i] * a[j][i];
      for (int i = 0; i < n; i++) b[i] = temp[i];
    }
    mult(a, n);
    pw /= 2;
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> m >> k;
  for (int i = 0; i < n; i++) cin >> bad[i];
  for (int i = 0; i < m; i++) {
    cin >> a >> b;
    --a, --b;
    g[a][b]++, g[b][a]++, deg[a]++, deg[b]++;
  }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++)
      if (bad[i] == 0)
        prob[i][j] = g[i][j] * 1.0 / deg[i];
      else
        prob[i][j] = (i == j);
  for (int iter = 1; iter <= 16; iter++) mult(prob, n);
  for (int i = 0; i < n; i++)
    if (bad[i])
      ind[i] = calc, ++calc;
    else
      ind[i] = -1;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++)
      if (ind[i] > -1 && ind[j] > -1) {
        for (int k = 0; k < n; k++) {
          if (ind[k] == -1) p1[ind[i]][ind[j]] += g[i][k] / deg[i] * prob[k][j];
        }
        p1[ind[i]][ind[j]] += g[i][j] * 1.0 / deg[i];
      }
  for (int i = 0; i < calc; i++) ans[i] = (i == ind[n - 1]);
  solve(p1, ans, k - 2, calc);
  answ = 0;
  for (int i = 0; i < n; i++)
    if (bad[i]) answ += prob[0][i] * ans[ind[i]];
  cout << answ << endl;
  cin.get();
  cin.get();
  return 0;
}