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, m, K, x, id[510], g[510][510], ues[510], s[510], y, tot;
bool vis[510], is[510];
double f[510][510], p[510], N[510][510];
vector<int> I;
double t1[110][110], t2[1][110], Add[510];
struct ma1 {
  double a[110][110];
  void Mul(double b[110][110]) {
    memset(t1, 0, sizeof(t1));
    for (int i = 0; i <= tot; i++)
      for (int j = 0; j <= tot; j++)
        for (int k = 0; k <= tot; k++) t1[i][k] += a[i][j] * b[j][k];
    for (int i = 0; i <= tot; i++)
      for (int j = 0; j <= tot; j++) a[i][j] = t1[i][j];
  }
} B[30];
struct ma2 {
  double a[1][110];
  void Mul(double b[110][110]) {
    memset(t2, 0, sizeof(t2));
    for (int i = 0; i < 1; i++)
      for (int j = 0; j <= tot; j++)
        for (int k = 0; k <= tot; k++) t2[i][k] += a[i][j] * b[j][k];
    for (int i = 0; i < 1; i++)
      for (int j = 0; j <= tot; j++) a[i][j] = t2[i][j];
  }
  void MulB(int y) {
    int t = 0;
    while (y) {
      if (y & 1) Mul(B[t].a);
      y >>= 1;
      t++;
    }
  }
} Ans;
void read(int &x) {
  char ch = getchar();
  int mark = 1;
  for (; ch != '-' && (ch < '0' || ch > '9'); ch = getchar())
    ;
  if (ch == '-') mark = -1, ch = getchar();
  for (x = 0; ch >= '0' && ch <= '9'; ch = getchar()) x = x * 10 + ch - 48;
  x *= mark;
}
void Make_f() {
  memset(f, 0, sizeof(f));
  for (int i = 1; i <= n; i++) {
    f[i][i] = -1;
    if (is[i]) continue;
    for (int j = 1; j <= n; j++) f[i][j] = (double)g[i][j] / s[j];
    f[i][i] = -1;
  }
}
void Special() {
  Make_f();
  memset(f[1], 0, sizeof(f[1]));
  f[1][0] = 1;
  f[1][1] = -1;
  memset(ues, 0, sizeof(ues));
  memset(vis, 0, sizeof(vis));
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++)
      if (f[j][i] && !vis[j]) {
        ues[i] = j;
        vis[j] = 1;
        break;
      }
    for (int k = 1; k <= n; k++)
      if (f[k][i] && ues[i] != k) {
        double tmp = -f[k][i] / f[ues[i]][i];
        for (int j = 0; j <= n; j++) f[k][j] += f[ues[i]][j] * tmp;
      }
  }
  for (int i = 1; i <= n; i++) p[i] = -f[ues[i]][0] / f[ues[i]][i];
}
void Work() {
  Make_f();
  memset(ues, 0, sizeof(ues));
  memset(vis, 0, sizeof(vis));
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++)
      if (f[j][i] && !vis[j]) {
        ues[i] = j;
        vis[j] = 1;
        break;
      }
    for (int k = 1; k <= n; k++)
      if (f[k][i] && ues[i] != k) {
        double tmp = N[i][k] = -f[k][i] / f[ues[i]][i];
        for (int j = 0; j <= n; j++) f[k][j] += f[ues[i]][j] * tmp;
      }
  }
  for (int i = 0; i < tot; i++) {
    for (int j = 1; j <= n; j++) p[j] = 0;
    p[I[i]] = 1;
    for (int j = 1; j <= n; j++)
      for (int k = 1; k <= n; k++) p[k] += p[j] * N[j][k];
    for (int j = 1; j <= n; j++) p[j] = -p[j] / f[ues[j]][j];
    double sum = 0;
    for (int j = 0; j < tot; j++)
      if (i != j)
        for (int k = 1; k <= n; k++)
          B[0].a[i + 1][j + 1] += p[k] * g[k][I[j]] / s[k];
    for (int j = 0; j < tot; j++) sum += B[0].a[i + 1][j + 1];
    B[0].a[i + 1][i + 1] = 1 - sum;
  }
}
int main() {
  read(n);
  read(m);
  read(K);
  for (int i = 1; i <= n; i++) {
    read(x);
    is[i] = x;
    if (is[i]) {
      I.push_back(i);
      id[i] = I.size();
    }
  }
  for (int i = 1; i <= m; i++) {
    read(x);
    read(y);
    g[x][y]++;
    g[y][x]++;
    s[x]++;
    s[y]++;
  }
  tot = I.size();
  Special();
  for (int i = 0; i < tot; i++)
    for (int j = 1; j <= n; j++) B[0].a[0][i + 1] += p[j] * g[j][I[i]] / s[j];
  double sum = 0;
  for (int i = 1; i <= tot; i++) sum += B[0].a[0][i];
  for (int i = 1; i <= tot; i++) B[0].a[0][i] /= sum;
  Work();
  for (int i = 1; i < 30; i++) {
    B[i] = B[i - 1];
    B[i].Mul(B[i - 1].a);
  }
  Ans.a[0][0] = 1;
  Ans.MulB(K - 1);
  printf("%.9lf\n", Ans.a[0][tot]);
  return 0;
}