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 nxt[100010 << 1], to[100010 << 1], head[510], in[510], cnt;
void add(int u, int v) {
  nxt[++cnt] = head[u];
  to[cnt] = v;
  head[u] = cnt;
  in[v]++;
}
int n;
static struct matrix {
  double num[510][510];
  matrix(int u = 0) {
    for (int i = 1; i <= n; i++) num[i][i] = u;
  }
} p;
matrix swp;
matrix operator*(const matrix &a, const matrix &b) {
  memset(swp.num, 0, sizeof(swp.num));
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++)
      for (int k = 1; k <= n; k++) swp.num[i][j] += a.num[i][k] * b.num[k][j];
  return swp;
}
matrix res;
matrix ksm(matrix a, long long k) {
  if (k == 0) return 1;
  if (k == 1) return a;
  res = ksm(a, k >> 1);
  if (k & 1)
    return res * res * a;
  else
    return res * res;
}
double num[510][510], val[510][510];
bool ban[510];
int hban[510], tot;
int cont[510];
double f[510][510];
int main() {
  int m;
  long long k;
  scanf("%d%d%lld", &n, &m, &k);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &ban[i]);
    if (ban[i]) hban[++tot] = i;
  }
  for (int i = 1; i <= m; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    add(u, v);
    add(v, u);
  }
  for (int i = 1; i <= n; i++) num[i][i] = 1;
  for (int i = 1; i <= n; i++) {
    val[i][i] = -1;
    for (int j = head[i]; j; j = nxt[j]) {
      int v = to[j];
      if (!ban[v]) val[i][v] += 1.0 / in[v];
    }
  }
  for (int i = 1; i <= n; i++) {
    int u = i;
    for (int j = i + 1; j <= n; j++)
      if (abs(val[u][i]) < abs(val[j][i])) u = j;
    for (int j = i; j <= n; j++) swap(val[i][j], val[u][j]);
    for (int j = 1; j <= n; j++)
      if (j != i) {
        double t = val[j][i] / val[i][i];
        for (int k = 1; k <= n; k++) {
          num[j][k] -= num[i][k] * t;
          val[j][k] -= val[i][k] * t;
        }
      }
  }
  hban[tot + 1] = 1;
  for (int i = 1; i <= tot + 1; i++) {
    memset(cont, 0, sizeof(cont));
    int u = hban[i];
    for (int j = head[u]; j; j = nxt[j]) cont[to[j]]++;
    for (int j = 1; j <= n; j++)
      if (abs(val[j][j]) > 1e-7) {
        for (int k = 1; k <= n; k++)
          f[u][j] += -1.0 / in[u] * cont[k] * num[j][k] / val[j][j];
      }
  }
  if (k == 2) {
    printf("%lf", f[1][n]);
    return 0;
  }
  n = tot;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) p.num[i][j] = f[hban[i]][hban[j]];
  p = ksm(p, k - 2);
  double ans = 0;
  for (int i = 1; i <= n; i++) ans += f[1][hban[i]] * p.num[i][n];
  printf("%.10lf", ans);
  return 0;
}