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 long long mod = 1000000007;
const int mxN = 510;
const int mxT = 110;
const double EPS = 1e-12;
double mat[mxN][mxN << 2];
double cnt[mxN][mxN];
vector<int> g[mxN];
bool dcr[mxN];
int N;
void gauss() {
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (dcr[j]) mat[i][j + N] = cnt[i][j] / g[i].size();
    }
  }
  for (int r = 0, col = 0; col < N; col++) {
    for (int s = r; s < N; s++) {
      if (fabs(mat[s][col]) >= EPS) {
        if (r != s)
          for (int c = 0; c < N + N; c++) swap(mat[r][c], mat[s][c]);
        break;
      }
    }
    if (fabs(mat[r][col]) < EPS) continue;
    for (int k = col + 1; k < N + N; k++) mat[r][k] /= mat[r][col];
    mat[r][col] = 1;
    for (int o = 0; o < N; o++) {
      if (o == r) continue;
      if (fabs(mat[o][col]) < EPS) continue;
      for (int c = col; c < N + N; c++)
        if (c != col) mat[o][c] -= mat[r][c] * mat[o][col];
      mat[o][col] = 0;
    }
    r++;
  }
  for (int i = 0; i < N; i++) {
    assert(fabs(mat[i][i] - 1.) < EPS);
    for (int j = 0; j < N; j++)
      if (i != j) assert(fabs(mat[i][j]) < EPS);
  }
}
double tmat[mxT][mxT], tmp[mxT][mxT], res[mxT][mxT];
int T = 0;
vector<int> t;
void pow_mod(int power) {
  for (int i = 0; i < T; i++) res[i][i] = 1.;
  while (power) {
    if (power & 1) {
      for (int i = 0; i < T; i++)
        for (int j = 0; j < T; j++) {
          tmp[i][j] = 0;
          for (int k = 0; k < T; k++) tmp[i][j] += tmat[i][k] * res[k][j];
        }
      for (int i = 0; i < T; i++)
        for (int j = 0; j < T; j++) res[i][j] = tmp[i][j];
    }
    {
      for (int i = 0; i < T; i++)
        for (int j = 0; j < T; j++) {
          tmp[i][j] = 0;
          for (int k = 0; k < T; k++) tmp[i][j] += tmat[i][k] * tmat[k][j];
        }
      for (int i = 0; i < T; i++)
        for (int j = 0; j < T; j++) tmat[i][j] = tmp[i][j];
    }
    power >>= 1;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed << setprecision(8);
  cerr << fixed << setprecision(2);
  int M, K, u, v;
  cin >> N >> M >> K;
  t.push_back(0);
  T = 1;
  for (int i = 0; i < N; i++) cin >> dcr[i], T += dcr[i];
  for (int i = 0; i < M; i++) {
    cin >> u >> v;
    u--, v--;
    g[u].push_back(v);
    g[v].push_back(u);
    cnt[u][v]++;
    cnt[v][u]++;
  }
  for (int i = 0; i < N; i++) {
    if (dcr[i]) t.push_back(i);
    mat[i][i] = 1.;
    double r = 1. / g[i].size();
    for (auto j : g[i])
      if (!dcr[j]) mat[i][j] -= r;
  }
  gauss();
  for (int i = 0; i < T; i++) {
    u = t[i];
    assert(fabs(mat[u][u] - 1.) < EPS);
    for (int j = 0; j < T; j++) {
      v = t[j];
      tmat[i][j] += mat[u][v + N];
    }
  }
  if (K < 2) {
    cout << 0.0 << '\n';
    return 0;
  }
  pow_mod(K - 1);
  cout << res[0][T - 1] << '\n';
  return 0;
}