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;
vector<vector<double> > Id;
template <typename T>
int solveGauss(vector<vector<T> >& A, vector<vector<T> >& b,
               vector<vector<T> >& sols) {
  int n = A.size(), m = A[0].size(), s = b.size();
  vector<int> pivots(n, -1);
  int k = 0, r = m;
  for (int e = 0; e < m and k < n; ++e) {
    int pivot = -1;
    for (int i = k; i < n and pivot == -1; ++i)
      if (A[i][e] != 0) pivot = i;
    if (pivot == -1) {
      for (int t = 0; t < s; ++t) {
        sols[t][e] = 0;
      }
      continue;
    }
    --r;
    pivots[k] = e;
    for (int i = 0; i < m; ++i) swap(A[pivot][i], A[k][i]);
    for (int t = 0; t < s; ++t) swap(b[t][pivot], b[t][k]);
    T inv = 1. / A[k][e];
    for (int j = e; j < m; ++j) A[k][j] = A[k][j] * inv;
    for (int t = 0; t < s; ++t) b[t][k] = b[t][k] * inv;
    for (int i = k + 1; i < n; ++i)
      for (int j = e + 1; j < m; ++j) A[i][j] = A[i][j] - A[i][e] * A[k][j];
    for (int t = 0; t < s; ++t)
      for (int i = k + 1; i < n; ++i) b[t][i] = b[t][i] - b[t][k] * A[i][e];
    for (int i = k + 1; i < n; ++i) A[i][e] = 0;
    ++k;
  }
  for (int i = k; i < n; ++i)
    for (int j = 0; j < m; ++j)
      if (A[i][j] != 0) return -1;
  for (int t = 0; t < s; ++t)
    for (int j = k; j < n; ++j)
      if (b[t][j] != 0) return -1;
  for (int t = 0; t < s; ++t)
    for (int i = n - 1; i >= 0; --i) {
      int d = pivots[i];
      if (d != -1 && d < sols[0].size()) {
        ;
        ;
        sols[t][d] = b[t][i];
        for (int j = d + 1; j < m; ++j) {
          sols[t][d] = sols[t][d] - A[i][j] * sols[t][j];
        }
      }
    }
  return r;
}
vector<vector<double> > multiply(vector<vector<double> >& a,
                                 vector<vector<double> >& b) {
  int n = a.size();
  vector<vector<double> > aux(n, vector<double>(n));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      for (int k = 0; k < n; k++) {
        aux[i][j] += a[i][k] * b[k][j];
      }
    }
  }
  return aux;
}
vector<vector<double> > raise(vector<vector<double> >& v, int e) {
  if (e == 0) return Id;
  if (e == 1) return v;
  vector<vector<double> > aux = raise(v, e / 2);
  aux = multiply(aux, aux);
  if (e % 2 == 1) aux = multiply(aux, v);
  return aux;
}
int main() {
  int n, m, k;
  cin >> n >> m >> k;
  vector<bool> traped(n);
  int a = 0, aux;
  for (int i = 0; i < n; i++) {
    cin >> aux;
    if (aux == 1)
      traped[i] = true;
    else
      traped[i] = false;
    if (traped[i]) ++a;
  }
  vector<double> sortint(n);
  vector<vector<double> > M(n, vector<double>(n)), TR(n, vector<double>(n));
  int x, y;
  for (int i = 0; i < m; i++) {
    cin >> x >> y;
    --x;
    --y;
    if (traped[y])
      TR[y][x] += 1.;
    else
      M[x][y] += 1.;
    ++sortint[x];
    swap(x, y);
    if (traped[y])
      TR[y][x] += 1.;
    else
      M[x][y] += 1.;
    ++sortint[x];
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      TR[i][j] /= sortint[j];
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      M[i][j] /= sortint[i];
      M[i][j] = -M[i][j];
      if (i == j) M[i][j] += 1.;
    }
  }
  vector<vector<double> > R(n, vector<double>(n));
  ;
  solveGauss(M, TR, R);
  vector<vector<double> > W(a, vector<double>(a, -3));
  int pos1 = 0, pos2 = 0;
  for (int i = 0; i < n; i++) {
    if (!traped[i]) continue;
    pos2 = 0;
    for (int j = 0; j < n; j++) {
      if (traped[j]) {
        W[pos1][pos2] = R[i][j];
        pos2++;
      }
    }
    pos1++;
  }
  Id = vector<vector<double> >(a, vector<double>(a));
  for (int i = 0; i < a; i++) Id[i][i] = 1.;
  W = raise(W, k - 2);
  double result = 0.;
  pos1 = 0;
  for (int i = 0; i < n; i++) {
    if (traped[i]) result += W[a - 1][pos1++] * R[i][0];
  }
  cout.precision(5);
  cout << fixed << result << endl;
}