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 double pi = acos(-1.0);
const double eps = 1e-8;
const int inf = 0x3f3f3f3f;
const int N = 500 + 11;
int imp[N];
vector<int> e[N];
vector<int> im;
double mat[N][N];
double rhs[N][N];
double vec[N];
int gauss(int n) {
  int rows = 0;
  int i, j, t;
  for (int col = 0; col < n; col++) {
    int next = rows;
    for (i = rows + 1; i < n; i++)
      if (fabs(mat[i][col]) > fabs(mat[next][col])) next = i;
    if (fabs(mat[next][col]) < 1e-4) continue;
    if (next != rows) {
      for (i = 0; i < n; i++) {
        swap(mat[next][i], mat[rows][i]);
        swap(rhs[next][i], rhs[rows][i]);
      }
    }
    double c = 1 / mat[rows][col];
    for (i = 0; i < n; i++) {
      mat[rows][i] *= c;
      rhs[rows][i] *= c;
    }
    for (i = rows + 1; i < n; i++) {
      double c = mat[i][col];
      for (j = 0; j < n; j++) {
        mat[i][j] -= mat[rows][j] * c;
        rhs[i][j] -= rhs[rows][j] * c;
      }
    }
    rows++;
  }
  for (i = rows - 1; i >= 0; i--) {
    int col = 0;
    while (fabs(mat[i][col]) < 1e-4) col++;
    if (col > i) {
      for (j = 0; j < n; j++) {
        swap(mat[i][j], mat[col][j]);
        swap(rhs[i][j], rhs[col][j]);
      }
      for (j = i; j < col; j++) {
        memset(mat[j], 0, sizeof(mat[j]));
        memset(rhs[j], 0, sizeof(rhs[j]));
        mat[j][j] = 1;
      }
    }
    for (j = col + 1; j < n; j++) {
      for (t = 0; t < n; t++) rhs[col][t] -= rhs[j][t] * mat[col][j];
      mat[col][j] = 0;
    }
  }
  return rows;
}
double TM[N][N];
void mul(double a[N][N], double b[N][N], int n, double c[N][N]) {
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      TM[i][j] = 0;
      for (int k = 0; k < n; ++k) {
        TM[i][j] = (TM[i][j] + a[i][k] * b[k][j]);
      }
    }
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      c[i][j] = TM[i][j];
    }
  }
}
void po(double a[N][N], int n, long long b, double c[N][N]) {
  int i;
  memset(c, 0, sizeof(c));
  for (i = 0; i < n; i++) c[i][i] = 1;
  while (b > 0) {
    if (b & 1) {
      mul(a, c, n, c);
    }
    mul(a, a, n, a);
    b >>= 1;
  }
}
double E[N][N];
double nxt[N][N];
int main() {
  int n, m, k, a, b, i, j, r;
  cin >> n >> m >> k;
  im.push_back(0);
  for (i = 0; i < n; i++) {
    scanf("%d", imp + i);
    if (imp[i]) im.push_back(i);
  }
  for (i = 0; i < m; i++) {
    scanf("%d%d", &a, &b);
    a--;
    b--;
    e[a].push_back(b);
    e[b].push_back(a);
  }
  memset(nxt, 0, sizeof(nxt));
  memset(mat, 0, sizeof(mat));
  memset(rhs, 0, sizeof(rhs));
  for (i = 0; i < n; i++) {
    mat[i][i] = rhs[i][i] = 1;
    double c = 1 / double(e[i].size());
    for (r = 0; r < e[i].size(); r++) {
      int v = e[i][r];
      if (!imp[v]) mat[i][v] -= c;
    }
  }
  gauss(n);
  for (i = 1; i <= im.size() - 1; i++) {
    memset(vec, 0, sizeof(vec));
    for (j = 0; j < n; j++) {
      mat[j][j] = 1;
      double c = 1 / double(e[j].size());
      for (r = 0; r < e[j].size(); r++) {
        int v = e[j][r];
        if (v == im[i]) vec[j] += c;
      }
    }
    for (j = 0; j < im.size(); j++) {
      for (r = 0; r < n; r++) {
        nxt[j][i] += rhs[im[j]][r] * vec[r];
      }
    }
  }
  k--;
  po(nxt, im.size(), k, E);
  printf("%.6lf\n", E[0][im.size() - 1]);
  return 0;
}