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;
ifstream f("wow.in");
int ind[506], V[506], pos[506];
double ai[506][506];
double fr[506][506], Pi[506];
double ai2[506][506], P[506], card[106];
double P2[106];
struct MAT {
  double e[106][106];
} aux, _mat, ML;
MAT mul(MAT A, MAT B, int n) {
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= n; ++j) {
      aux.e[i][j] = 0;
      for (int t = 1; t <= n; ++t) aux.e[i][j] += A.e[i][t] * B.e[t][j];
    }
  return aux;
}
void sub(double i1[], double i2[], int n, double coef) {
  for (int i = 1; i <= n; ++i) i1[i] += i2[i] * coef;
}
void gauss(double A[][506], int n, int nrb) {
  int i, j;
  for (i = 1; i <= n; ++i) {
    fr[i][i]++;
    A[i][i] = (i <= nrb ? 1 : card[i]);
  }
  for (i = 1; i <= n; ++i) {
    for (j = i; j <= n; ++j)
      if (A[j][i] < -0.0000000000001 || A[j][i] > 0.0000000000001) {
        swap(A[i], A[j]);
        swap(fr[i], fr[j]);
        break;
      }
    for (j = i + 1; j <= n; ++j)
      if (A[j][i] < -0.0000000000001 || A[j][i] > 0.0000000000001) {
        double cf = -A[j][i] / A[i][i];
        sub(A[j], A[i], n, cf);
        sub(fr[j], fr[i], n, cf);
      }
  }
  for (i = n; i > 0; --i) {
    for (j = 1; j < i; ++j) {
      double cf = -A[j][i] / A[i][i];
      sub(A[j], A[i], n, cf);
      sub(fr[j], fr[i], n, cf);
    }
  }
}
int main() {
  cout << fixed;
  cout << setprecision(5);
  int n, m, i, j, nrb = 0, nra = 0, K;
  cin >> n >> m >> K;
  for (i = 1; i <= n; ++i) {
    cin >> V[i];
    if (V[i]) pos[i] = (++nrb);
  }
  for (i = 1; i <= n; ++i)
    if (V[i] == 0) pos[i] = nrb + (++nra);
  for (i = 1; i <= m; ++i) {
    int xx, yy;
    cin >> xx >> yy;
    if (pos[xx] > nrb) ai[pos[xx]][pos[yy]]--;
    if (pos[yy] > nrb) ai[pos[yy]][pos[xx]]--;
    ai2[pos[xx]][pos[yy]]++, ai2[pos[yy]][pos[xx]]++;
    card[pos[yy]]++, card[pos[xx]]++;
  }
  gauss(ai, n, nrb);
  for (i = 1; i <= nrb; ++i) {
    for (j = 1; j <= nrb; ++j) P[j] = 0;
    for (j = nrb + 1; j <= n; ++j) P[j] = fr[j][i] / ai[j][j];
    P[i] = 1;
    Pi[i] = P[pos[1]];
    for (j = 1; j <= nrb; ++j) {
      P2[j] = 0;
      for (int k = 1; k <= n; ++k) P2[j] += ai2[j][k] * P[k];
      ML.e[j][i] = (P2[j] /= card[j]);
    }
    for (j = 1; j <= nrb; ++j) P[j] = P2[j];
  }
  for (i = 1; i <= n; ++i) _mat.e[i][i] = 1;
  K -= 2;
  for (i = 30; i >= 0; --i) {
    _mat = mul(_mat, _mat, nrb);
    if (K & (1 << i)) _mat = mul(_mat, ML, nrb);
  }
  double result = 0;
  for (i = 1; i <= n; ++i) result += _mat.e[i][pos[n]] * Pi[i];
  cout << result << '\n';
  return 0;
}