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;
int n;
int m;
int k;
int flag[502];
vector<double> g[502];
double deg[502];
double cnt[502][502];
double dist[502][502];
const int matrix_size = 102;
struct matrix {
  double mat[matrix_size][matrix_size];
  matrix() { memset(mat, 0, sizeof(mat)); }
};
matrix operator*(const matrix &a, const matrix &b) {
  matrix r;
  double tmp;
  for (int i = 0; i < matrix_size; i++) {
    for (int j = 0; j < matrix_size; j++) {
      tmp = 0;
      for (int k = 0; k < matrix_size; k++) {
        tmp += (double)(a.mat[i][k]) * b.mat[k][j];
      }
      r.mat[i][j] = tmp;
    }
  }
  return r;
}
matrix operator+(const matrix &a, const matrix &b) {
  matrix r;
  for (int i = 0; i < matrix_size; i++) {
    for (int j = 0; j < matrix_size; j++) {
      r.mat[i][j] += a.mat[i][j] + b.mat[i][j];
    }
  }
  return r;
}
matrix ppow(matrix i, long long int j) {
  if (j == 0) {
    for (int i1 = 0; i1 < matrix_size; i1++) {
      for (int j = 0; j < matrix_size; j++) {
        i.mat[i1][j] = (i1 == j);
      }
    }
    return i;
  }
  if (j == 1LL) {
    return i;
  }
  j--;
  matrix r = i;
  while (j) {
    if ((j & 1LL)) {
      r = r * i;
    }
    i = i * i;
    j >>= 1LL;
  }
  return r;
}
vector<int> v;
matrix mat;
int idx[502];
int main() {
  cin >> n >> m >> k;
  for (int i = 0; i < n; i++) {
    scanf("%d", &flag[i]);
    if (i == 0 || flag[i]) {
      v.push_back(i);
    }
  }
  for (int i = 0; i < m; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    a--;
    b--;
    cnt[a][b] += 1;
    cnt[b][a] += 1;
    deg[a]++;
    deg[b]++;
  }
  for (int i = 0; i < n; i++) {
    g[i].assign(n * 2, 0);
    g[i][i] = -1;
    if (flag[i] == false) {
      for (int j = 0; j < n; j++) {
        if (j != i) {
          g[i][j] = cnt[i][j] / deg[i];
        }
      }
    } else {
      g[i][i + n] = 1;
      g[i][i] = 1;
    }
  }
  for (int i = 0; i < n; i++) {
    double mx = 0;
    int id = -1;
    for (int j = i; j < n; j++) {
      mx = max(mx, fabs(g[j][i]));
      if (mx == fabs(g[j][i])) {
        id = j;
      }
    }
    if (mx == 0.0) continue;
    swap(g[i], g[id]);
    double pr = g[i][i];
    for (int j = i + 1; j < n; j++) {
      double rat = g[j][i] / pr;
      for (int k = i; k < n * 2; k++) {
        g[j][k] -= rat * g[i][k];
      }
    }
  }
  for (int k = 0; k < n; k++) {
    if (flag[k] == false) continue;
    dist[k][k] = 1;
    for (int i = n - 1; i >= 0; i--) {
      if (flag[i]) continue;
      double r = 0;
      r = g[i][k + n];
      for (int j = n - 1; j > i; j--) {
        r -= dist[j][k] * g[i][j];
      }
      r /= g[i][i];
      dist[i][k] = r;
    }
    for (int i = 0; i < n; i++) {
      if (flag[i] && i != k) {
        for (int j = 0; j < n; j++) {
          if (i != j) {
            if (j == k || flag[j] == false) {
              dist[i][k] += dist[j][k] * cnt[i][j] / deg[i];
            }
          }
        }
      }
    }
    int i = k;
    dist[i][k] = 0;
    for (int j = 0; j < n; j++) {
      if (i != j) {
        if (j == k || flag[j] == false) {
          dist[i][k] += dist[j][k] * cnt[i][j] / deg[i];
        }
      }
    }
  }
  int c = -1;
  for (int id : v) {
    c++;
    idx[id] = c;
  }
  for (int id : v) {
    for (int go : v) {
      if (go == 0) continue;
      double &pro = dist[id][go];
      mat.mat[idx[go]][idx[id]] = pro;
    }
  }
  mat = ppow(mat, k - 1);
  double ans = mat.mat[c][0];
  printf("%.16f\n", ans);
  return 0;
}