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 NMax = 505;
int N, M, K;
double Res[NMax], Prob[NMax][NMax], Sol[NMax][NMax], P[NMax][NMax],
    Aux[NMax][NMax], Coef[NMax][NMax], S[NMax][NMax], tProb[NMax][NMax];
int Trap[NMax];
vector<int> G[NMax];
struct Operation {
  int type;
  int x, y;
  double mul, add;
} Op[NMax * NMax * 4];
int Ord[NMax], tCells[NMax], cnt, op;
void Read() {
  scanf("%d%d%d", &N, &M, &K);
  for (int i = 1; i <= N; i++) {
    scanf("%d", &Trap[i]);
    if (Trap[i]) tCells[++cnt] = i;
  }
  for (int i = 1; i <= M; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    G[x].push_back(y);
    G[y].push_back(x);
  }
}
void buildCoef() {
  for (int i = 1; i <= N; i++) {
    if (Trap[i])
      Coef[i][i] = 1.0;
    else {
      for (int j = 0; j < G[i].size(); j++) {
        int neighb = G[i][j];
        Coef[i][neighb] = Prob[i][neighb];
      }
      Coef[i][i] = -1.0;
    }
  }
}
void Gauss() {
  int i = 1, j = 1;
  while (i <= N && j <= N) {
    int k;
    for (k = i; k <= N && Coef[k][j] == 0; k++)
      ;
    if (k == N + 1) {
      ++j;
      continue;
    }
    if (i != k) {
      Op[++op] = {1, i, k, 0, 0};
      swap(Coef[i], Coef[k]);
    }
    for (k = i + 1; k <= N; k++) {
      if (Coef[k][j] != 0) {
        Op[++op] = {2, i, k, Coef[k][j] / Coef[i][j], 0};
        for (int p = j + 1; p <= N; p++)
          Coef[k][p] -= Coef[i][p] * (Coef[k][j] / Coef[i][j]);
        Coef[k][j] = 0;
      }
    }
    ++i;
    ++j;
  }
}
void buildProb() {
  for (int i = 1; i <= N; i++) {
    double prob = 1.0 / G[i].size();
    for (int j = 0; j < G[i].size(); j++)
      Prob[i][G[i][j]] += prob, tProb[i][G[i][j]] += prob;
  }
  for (int i = 1; i <= N; i++) {
    sort(G[i].begin(), G[i].end());
    G[i].erase(unique(G[i].begin(), G[i].end()), G[i].end());
  }
  buildCoef();
  Gauss();
  for (int i = 1; i <= N; i++) {
    if (!Trap[i]) continue;
    for (int j = 1; j <= N; j++) Res[j] = 0;
    Res[i] = 1;
    for (int j = 1; j <= N; j++) Ord[j] = j;
    for (int k = 1; k <= op; k++) {
      if (Op[k].type == 1) {
        swap(Res[Op[k].x], Res[Op[k].y]);
        swap(Ord[Op[k].x], Ord[Op[k].y]);
      } else
        Res[Op[k].y] -= Res[Op[k].x] * Op[k].mul;
    }
    for (int j = N; j >= 1; j--) {
      for (int k = N; k > j; k--) Res[j] -= Res[k] * Coef[j][k];
      Res[j] /= Coef[j][j];
      Prob[Ord[j]][i] = Res[j];
    }
    for (int j = 1; j <= N; j++) {
      int node = Ord[j];
      for (int k = 0; k < G[node].size(); k++) {
        int neighb = G[node][k];
        S[node][i] += tProb[node][neighb] * Prob[neighb][i];
      }
    }
  }
}
void royFloyd() {
  for (int k = 1; k <= N; k++) {
    if (Trap[k]) continue;
    for (int i = 1; i <= N; i++) {
      for (int j = 1; j <= N; j++) {
        Prob[i][j] += Prob[i][k] * Prob[k][j];
      }
    }
  }
}
void multiply(double A[][NMax], double B[][NMax], double C[][NMax]) {
  for (int i = 1; i <= cnt; i++) {
    for (int j = 1; j <= cnt; j++) {
      C[i][j] = 0;
      for (int k = 1; k <= cnt; k++) C[i][j] += A[i][k] * B[k][j];
    }
  }
  for (int i = 1; i <= cnt; i++)
    for (int j = 1; j <= cnt; j++) A[i][j] = C[i][j];
}
void initSol() {
  for (int i = 1; i <= cnt; i++) Sol[i][i] = 1.0;
}
void power(int p) {
  initSol();
  while (p) {
    if (p % 2 == 1) multiply(Sol, P, Aux);
    p /= 2;
    multiply(P, P, Aux);
  }
}
void initializeP() {
  for (int i = 1; i <= cnt; i++) {
    for (int j = 1; j <= cnt; j++) P[i][j] = S[tCells[j]][tCells[i]];
  }
}
void Solve() {
  power(K - 2);
  for (int i = 1; i <= cnt; i++) {
    for (int j = 1; j <= cnt; j++) Aux[i][j] = 0;
  }
  Aux[1][cnt] = 1.0;
  multiply(Aux, Sol, P);
  double ans = 0.0;
  for (int i = 1; i <= cnt; i++) {
    ans += S[1][tCells[i]] * Aux[1][i];
  }
  printf("%.15f\n", ans);
}
int main() {
  Read();
  buildProb();
  initializeP();
  if (K == 2) {
    printf("%.15f\n", Prob[1][N]);
    return 0;
  }
  Solve();
  return 0;
}