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 INF = 1000000000;
const long long INFL = 1000000000000000000;
const int MAXN = 512;
int N, M, K;
int trap[MAXN];
vector<int> ve[MAXN];
double norg[2][MAXN][MAXN];
double npow[2][MAXN][MAXN];
int trapi[512] = {0};
int T = 1;
void mult(double A[MAXN][MAXN], double B[MAXN][MAXN], double C[MAXN][MAXN]) {
  for (int i = (0); i < (T); i++)
    for (int j = (0); j < (T); j++) {
      C[i][j] = 0;
      for (int k = (0); k < (T); k++) C[i][j] += A[i][k] * B[k][j];
    }
}
double mat[MAXN][MAXN];
double rhs[MAXN][MAXN];
double vec[MAXN];
void gauss() {
  int rows = 0;
  for (int col = (0); col < (N); col++) {
    int next = rows;
    for (int i = (rows + 1); i < (N); i++)
      if (abs(mat[i][col]) > abs(mat[next][col])) next = i;
    if (abs(mat[next][col]) < 1e-4) continue;
    if (next != rows) {
      for (int i = (0); i < (N); i++) swap(mat[next][i], mat[rows][i]);
      for (int i = (0); i < (N); i++) swap(rhs[next][i], rhs[rows][i]);
    }
    double c = 1 / mat[rows][col];
    for (int i = (0); i < (N); i++) mat[rows][i] *= c, rhs[rows][i] *= c;
    for (int i = (rows + 1); i < (N); i++) {
      double c = mat[i][col];
      for (int j = (0); j < (N); j++)
        mat[i][j] -= mat[rows][j] * c, rhs[i][j] -= rhs[rows][j] * c;
    }
    rows++;
  }
  for (int i = (rows)-1; i >= 0; i--) {
    int col = 0;
    while (abs(mat[i][col]) < 1e-4) col++;
    if (col > i) {
      for (int j = (0); j < (N); j++) swap(mat[i][j], mat[col][j]);
      for (int j = (0); j < (N); j++) swap(rhs[i][j], rhs[col][j]);
      for (int j = (i); j < (col); j++) {
        memset(mat[j], 0, sizeof mat[j]);
        memset(rhs[j], 0, sizeof rhs[j]);
        mat[j][j] = 1;
      }
    }
    for (int j = (col + 1); j < (N); j++) {
      for (int k = (0); k < (N); k++) rhs[col][k] -= rhs[j][k] * mat[col][j];
      mat[col][j] = 0;
    }
  }
}
int main() {
  scanf("%d%d%d", &N, &M, &K);
  for (int i = (0); i < (N); i++) {
    scanf("%d", &trap[i]);
    if (trap[i]) trapi[T++] = i;
  }
  for (int i = (0); i < (M); i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    a--, b--;
    ve[a].push_back(b);
    ve[b].push_back(a);
  }
  memset(norg, 0, sizeof norg);
  memset(npow, 0, sizeof npow);
  memset(mat, 0, sizeof mat);
  memset(rhs, 0, sizeof rhs);
  for (int i = (0); i < (N); i++) {
    mat[i][i] = rhs[i][i] = 1;
    double c = 1 / double(ve[i].size());
    for (int j = (0); j < (ve[i].size()); j++) {
      if (!trap[ve[i][j]]) mat[i][ve[i][j]] -= c;
    }
  }
  gauss();
  for (int t = (1); t < (T); t++) {
    for (int i = (0); i < (N); i++) {
      double c = 1 / double(ve[i].size());
      vec[i] = 0;
      for (int j = (0); j < (ve[i].size()); j++)
        if (ve[i][j] == trapi[t]) vec[i] += c;
    }
    for (int i = (0); i < (T); i++)
      for (int j = (0); j < (N); j++)
        norg[0][i][t] += rhs[trapi[i]][j] * vec[j];
  }
  for (int t = (0); t < (T); t++) npow[0][t][t] = 1;
  K--;
  int cura = 0, curb = 0;
  while (K) {
    if (K & 1) mult(npow[curb], norg[cura], npow[1 - curb]), curb = 1 - curb;
    mult(norg[cura], norg[cura], norg[1 - cura]), cura = 1 - cura;
    K /= 2;
  }
  printf("%lf", npow[curb][0][T - 1]);
  return 0;
}