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;
template <class T>
void debug(T a, T b) {
  ;
}
template <class T>
void chmin(T& a, const T& b) {
  if (a > b) a = b;
}
template <class T>
void chmax(T& a, const T& b) {
  if (a < b) a = b;
}
int n, m;
long long int k;
int g[505][505];
int mark[505];
vector<double> mat[505];
int ps[505], deg[505];
double prob[70][505][505];
double ans[505][505];
double tmp[505][505];
int cnt;
void merge(double a[505][505], double b[505][505]) {
  for (int i = 0; i < (cnt); ++i)
    for (int j = 0; j < (cnt); ++j) {
      tmp[i][j] = 0;
      for (int k = 0; k < (cnt); ++k) tmp[i][j] += a[i][k] * b[k][j];
    }
  memcpy(a, tmp, sizeof(tmp));
}
int main() {
  cin >> n >> m >> k;
  --k;
  for (int i = 0; i < (n); ++i) cin >> mark[i];
  for (int i = 0; i < (m); ++i) {
    int a, b;
    cin >> a >> b;
    --a;
    --b;
    g[a][b]++;
    g[b][a]++;
    deg[a]++;
    deg[b]++;
  }
  cnt = 0;
  for (int i = 0; i < (n); ++i)
    if (i == 0 || mark[i]) ps[cnt++] = i;
  for (int i = 0; i < (n); ++i) mat[i].resize(n * 2);
  for (int i = 0; i < (n); ++i) {
    if (!mark[i]) {
      for (int j = 0; j < (n); ++j) mat[i][j] = 1.0 * g[i][j] / deg[i];
    } else {
      mat[i][n + i] = 1;
    }
    mat[i][i] = -1;
  }
  for (int i = 0; i < (n); ++i) {
    double mx = -1;
    int ind;
    for (int j = i; j < n; ++j)
      if (abs(mat[j][i]) > mx) {
        mx = abs(mat[j][i]);
        ind = j;
      }
    swap(mat[ind], mat[i]);
    double prev = mat[i][i];
    for (int j = 0; j < (n * 2); ++j) mat[i][j] /= prev;
    for (int j = 0; j < (n); ++j)
      if (j != i && mat[j][i] != 0) {
        for (int k = 0; k < (n * 2); ++k)
          if (i != k) mat[j][k] -= mat[i][k] * mat[j][i];
        mat[j][i] = 0;
      }
  }
  for (int i = 0; i < (cnt); ++i)
    for (int j = 0; j < (cnt); ++j) {
      int a = ps[i], b = ps[j];
      if (mark[a]) {
        prob[0][i][j] = 0;
        for (int k = 0; k < (n); ++k) {
          prob[0][i][j] -= mat[k][n + b] * g[a][k] / deg[a];
        }
      } else {
        prob[0][i][j] = -mat[a][n + b];
      }
    }
  for (int i = 0; i < (61); ++i) {
    memcpy(prob[i + 1], prob[i], sizeof(prob[i]));
    merge(prob[i + 1], prob[i]);
  }
  for (int i = 0; i < (cnt); ++i) debug(prob[1][i], prob[1][i] + cnt);
  ans[0][0] = 1;
  for (int i = 0; i < (61); ++i)
    if (k >> i & 1) merge(ans, prob[i]);
  double res = ans[0][cnt - 1];
  for (int i = 0; i < (cnt); ++i) debug(ans[i], ans[i] + cnt);
  printf("%.10f\n", res);
  return 0;
}