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, int N>
struct matrix {
  T a[N][N];
  int n;
  matrix(int _n = N) : n(_n) {
    for (int i = 0; i < n; i++)
      for (int j = 0; j < n; j++) a[i][j] = T();
  }
  T* operator[](int x) { return a[x]; }
  const T* operator[](int x) const { return a[x]; }
  static matrix eye(int n = N) {
    matrix t(n);
    for (int i = 0; i < n; i++) t[i][i] = 1;
    return t;
  }
  matrix operator*(const matrix& b) const {
    matrix c(n);
    for (int i = 0; i < n; i++)
      for (int j = 0; j < n; j++)
        for (int k = 0; k < n; k++) c[i][k] += a[i][j] * b[j][k];
    return c;
  }
  matrix& operator*=(const matrix& b) { return *this = *this * b; }
  template <class U>
  matrix operator^(U arg) const {
    if (arg == 0) return matrix::eye(n);
    if (arg == 1) return *this;
    auto t = *this ^ (arg >> 1);
    t *= t;
    if (arg & 1) t *= *this;
    return t;
  }
  template <class U>
  matrix operator^=(U arg) {
    return *this = *this ^ arg;
  }
};
int n, m, k;
int e[505][505], deg[505];
int a[505];
valarray<long double> g[505], h[505], cv[505], cv2[505];
void gadd(valarray<long double> b, valarray<long double> c) {
  for (int i = 0; i < n; i++) {
    if (abs(g[i][i]) < 1e-12) {
      g[i] = b;
      h[i] = c;
      return;
    } else {
      long double q = b[i] / g[i][i];
      b -= g[i] * q;
      c -= h[i] * q;
    }
  }
}
valarray<long double> gtest(valarray<long double> b) {
  valarray<long double> c(n);
  for (int i = 0; i < n; i++) {
    if (abs(g[i][i]) < 1e-12) {
    } else {
      long double q = b[i] / g[i][i];
      b -= g[i] * q;
      c += h[i] * q;
    }
  }
  return c;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cerr.tie(nullptr);
  cin >> n >> m >> k;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) g[i].resize(n), h[i].resize(n), cv2[i].resize(n);
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    u--, v--;
    e[u][v] += 1;
    e[v][u] += 1;
    deg[u] += 1;
    deg[v] += 1;
  }
  for (int i = 0; i < n; i++) {
    valarray<long double> b(n), c(n);
    if (a[i]) {
      b[i] = 1;
      c[i] = 1;
    } else {
      for (int j = 0; j < n; j++) b[j] = e[i][j];
      b[i] = -deg[i];
    }
    gadd(b, c);
  }
  for (int i = 0; i < n; i++) {
    valarray<long double> b(n);
    b[i] = 1;
    cv[i] = gtest(b);
  }
  int kamen = count(a, a + n, 1);
  for (int i = 0; i < n; i++) {
    if (a[i]) {
      for (int j = 0; j < n; j++) {
        cv2[i] += cv[j] * ((long double)e[i][j] / deg[i]);
      }
    } else {
      cv2[i] = cv[i];
    }
  }
  matrix<long double, 101> z(kamen);
  int ii = 0;
  for (int i = 0; i < n; i++) {
    if (!a[i]) continue;
    int jj = 0;
    for (int j = 0; j < n; j++) {
      if (!a[j]) continue;
      z[ii][jj] = cv2[i][j];
      jj++;
    }
    ii++;
  }
  z ^= k - 2;
  long double sol = 0;
  ii = 0;
  for (int i = 0; i < n; i++) {
    if (!a[i]) continue;
    sol += cv[0][i] * z[ii][kamen - 1];
    ii++;
  }
  cout << setprecision(20) << fixed << sol << '\n';
}