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;
vector<int> ar, tr;
vector<vector<int> > a;
vector<vector<long double> > p;
int main() {
  cout << setprecision(10) << fixed;
  int n, m, k;
  cin >> n >> m >> k;
  tr.resize(n);
  for (int i = 0; i < n; i++) cin >> tr[i];
  a.resize(n);
  for (int i = 0; i < n; i++) {
    a[i].resize(n);
  }
  vector<int> d(n, 0);
  for (int i = 0; i < m; i++) {
    int first, second;
    cin >> first >> second;
    first--, second--;
    a[first][second]++;
    a[second][first]++;
    d[first]++;
    d[second]++;
  }
  ar.resize(n);
  int c = 0, cc = 0;
  for (int i = 0; i < n; i++) {
    if (tr[i] == 0)
      ar[i] = c++;
    else
      ar[i] = cc++;
  }
  p.resize(cc);
  for (int i = 0; i < cc; i++) p[i].resize(n, 0);
  vector<vector<long double> > q(n, vector<long double>(n));
  vector<long double> pp(n);
  for (int i = 0; i < n; i++) {
    if (tr[i] == 0) {
      for (int j = 0; j < n; j++) q[i][j] = 0;
      for (int j = 0; j < n; j++) {
        q[i][j] += 1.0 * a[i][j] / d[i];
      }
      for (int j = 0; j < i; j++) {
        if (tr[j] == 0) {
          for (int ij = 0; ij < n; ij++) {
            q[i][ij] += q[i][j] * q[j][ij];
          }
          q[i][j] = 0;
        }
      }
      for (int j = 0; j < n; j++) {
        if (tr[j] || j > i) q[i][j] /= (1 - q[i][i]);
      }
      q[i][i] = 0;
    }
  }
  for (int _ = 0; _ < cc; _++) {
    for (int i = 0; i < n; i++) {
      if (tr[i] && ar[i] == _)
        pp[i] = 1;
      else
        pp[i] = 0;
    }
    for (int i = n - 1; i >= 0; i--) {
      if (tr[i] == 0) {
        pp[i] = 0;
        for (int j = 0; j < n; j++) pp[i] += q[i][j] * pp[j];
      }
    }
    for (int i = 0; i < n; i++) p[_][i] = pp[i];
  }
  vector<vector<long double> > P(cc + 1, vector<long double>(cc, 0));
  for (int i = 0; i < cc; i++) {
    int ij = 0;
    while (tr[ij] == 0 || ar[ij] != i) ij++;
    for (int j = 0; j < cc; j++) {
      for (int ii = 0; ii < n; ii++) {
        P[i][j] += a[ij][ii] * p[j][ii] / d[ij];
      }
    }
  }
  for (int i = 0; i < cc; i++) {
    P[cc][i] = p[i][0];
  }
  k--;
  vector<vector<vector<long double> > > A(
      30, vector<vector<long double> >(cc, vector<long double>(cc)));
  for (int i = 0; i < cc; i++) {
    for (int j = 0; j < cc; j++) {
      A[0][i][j] = P[i][j];
    }
  }
  for (int _ = 1; _ < 30; _++) {
    for (int i = 0; i < cc; i++) {
      for (int j = 0; j < cc; j++) {
        A[_][i][j] = 0;
        for (int ij = 0; ij < cc; ij++) {
          A[_][i][j] += A[_ - 1][i][ij] * A[_ - 1][ij][j];
        }
      }
    }
  }
  vector<vector<long double> > B(cc, vector<long double>(cc, 0)),
      C(cc, vector<long double>(cc, 0));
  for (int i = 0; i < cc; i++) B[i][i] = 1;
  int cccc = 0;
  k--;
  while (k > 0) {
    if (k % 2 == 1) {
      for (int i = 0; i < cc; i++) {
        for (int j = 0; j < cc; j++) {
          C[i][j] = 0;
          for (int ij = 0; ij < cc; ij++) {
            C[i][j] += B[i][ij] * A[cccc][ij][j];
          }
        }
      }
      swap(B, C);
    }
    cccc++;
    k /= 2;
  }
  long double res = 0;
  for (int i = 0; i < cc; i++) res += B[i][cc - 1] * P[cc][i];
  cout << res << "\n";
  return 0;
}