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 MAXN = 510;
const int MAXS = 110;
const int MAXM = 1E5 + 10;
const double EPS = 1E-8;
int siz, n, m, k, ban[MAXN], pos[MAXN], U[MAXM], V[MAXM], d[MAXN], id[MAXN];
vector<int> G[MAXN];
struct Mat {
  double a[MAXS][MAXS];
  Mat() { memset(a, 0, sizeof a); }
  double* operator[](int x) { return a[x]; }
  const double* operator[](int x) const { return a[x]; }
  Mat operator*(const Mat& rhs) const {
    Mat ret;
    for (int i = 0; i <= siz; i++)
      for (int j = 0; j <= siz; j++)
        for (int k = 0; k <= siz; k++) ret[i][j] += a[i][k] * rhs[k][j];
    return ret;
  }
} trans;
Mat ksm(Mat a, long long b) {
  Mat ret;
  for (int i = 0; i <= siz; i++) ret[i][i] = 1;
  for (; b; b >>= 1, a = a * a)
    if (b & 1) ret = ret * a;
  return ret;
}
double A[MAXN][MAXN << 1], C[MAXN], X[MAXN];
void Guass() {
  for (int i = 1; i <= n; i++) {
    int pos = i;
    for (int j = i + 1; j <= n; j++)
      if (abs(A[j][i]) > abs(A[pos][i])) pos = j;
    if (abs(A[pos][i]) < EPS) throw "No Matrix Inverse";
    for (int j = 1; j <= 2 * n; j++) swap(A[pos][j], A[i][j]);
    for (int j = i + 1; j <= n; j++) {
      if (abs(A[j][i]) < EPS) continue;
      double coef = A[j][i] / A[i][i];
      for (int k = 1; k <= 2 * n; k++) A[j][k] -= A[i][k] * coef;
    }
  }
  for (int i = n; i; i--) {
    double inv = 1.0 / A[i][i];
    for (int j = 1; j <= 2 * n; j++) A[i][j] = A[i][j] * inv;
    for (int j = i - 1; j; j--) {
      double coef = A[j][i] / A[i][i];
      for (int k = 1; k <= 2 * n; k++) A[j][k] -= A[i][k] * coef;
    }
  }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) swap(A[i][j], A[i][j + n]);
}
void solve() {
  for (int i = 1; i <= n; i++) X[i] = 0;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) X[j] += C[i] * A[j][i];
}
int main() {
  scanf("%d%d%d", &n, &m, &k);
  pos[++siz] = 1;
  id[1] = 1;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &ban[i]);
    if (ban[i]) pos[++siz] = i, id[i] = siz;
  }
  for (int i = 1; i <= n; i++) A[i][i] = A[i][i + n] = 1;
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &U[i], &V[i]);
    G[U[i]].push_back(V[i]);
    G[V[i]].push_back(U[i]);
    ++d[U[i]];
    ++d[V[i]];
  }
  for (int i = 1; i <= m; i++) {
    int u = U[i], v = V[i];
    if (!ban[u]) A[v][u] -= 1.0 / d[u];
    if (!ban[v]) A[u][v] -= 1.0 / d[v];
  }
  Guass();
  for (int i = 1; i <= siz; i++) {
    memset(C, 0, sizeof C);
    int x = pos[i];
    if (x == 1)
      C[1] = 1, solve();
    else {
      C[x] = 1;
      for (int v : G[x]) C[v] += 1.0 / d[x];
      solve();
    }
    double tot = 1;
    for (int j = 1; j <= n; j++)
      if (ban[j] && j != x) trans[i][id[j]] = X[j], tot -= X[j];
    trans[i][i] = tot;
  }
  trans[siz][0] = 1;
  Mat res;
  res[0][1] = 1;
  res = res * ksm(trans, k);
  printf("%.10lf\n", res[0][0]);
}