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 int N = 502;
const double EPS = 1e-10;
int n, m, k, a[N], mp[N][N], idx[N];
vector<int> g[N];
double mat[N][N], p[N][N], b[N];
struct order {
  int type;
  int x, y;
  double k;
} O[1000000 + 10];
int tot = 0;
void gauss() {
  for (int i = 0; i < n; i++) {
    int cnt = 0;
    for (int j = 0; j < n; j++) {
      if (mp[i][j]) {
        cnt += mp[i][j];
      }
    }
    for (int j = 0; j < n; j++) {
      if (i == j) {
        mat[i][j] = 1.0;
      }
      if (mp[i][j] && a[i] == 0) {
        mat[j][i] = -1.0 * mp[i][j] / cnt;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    if (abs(mat[i][i]) < EPS) {
      for (int j = i; j < n; j++) {
        if (abs(mat[j][i]) > EPS) {
          O[++tot].type = 1, O[tot].x = i, O[tot].y = j;
          for (int k = 0; k < n; k++) {
            swap(mat[i][k], mat[j][k]);
          }
          break;
        }
      }
    }
    for (int j = i + 1; j < n; j++) {
      if (abs(mat[j][i]) > EPS) {
        double r = mat[j][i] / mat[i][i];
        O[++tot].type = 2, O[tot].x = i, O[tot].y = j, O[tot].k = -r;
        for (int k = 0; k < n; k++) {
          mat[j][k] -= r * mat[i][k];
        }
      }
    }
  }
  for (int i = n - 1; i >= 0; i--) {
    if (abs(mat[i][i]) > EPS) {
      for (int j = i - 1; j >= 0; j--) {
        O[++tot].type = 2, O[tot].x = i, O[tot].y = j,
        O[tot].k = -mat[j][i] / mat[i][i];
        mat[j][i] = 0;
      }
    }
  }
}
void solve(int u) {
  int deg = 0;
  for (int i = 0; i < n; i++)
    if (mp[u][i]) deg += mp[u][i];
  for (int i = 0; i < n; i++) {
    b[i] = 0;
    for (int j = 0; j < n; j++) {
      if (mp[i][j] && j == u) b[i] = 1.0 * mp[i][j] / deg;
    }
  }
  for (int i = 1; i <= tot; i++) {
    if (O[i].type == 1) {
      swap(b[O[i].x], b[O[i].y]);
    } else {
      b[O[i].y] += b[O[i].x] * O[i].k;
    }
  }
  for (int i = 0; i < n; i++) {
    if (idx[i] != -1) {
      p[idx[u]][idx[i]] = b[i] / mat[i][i];
    }
  }
}
int now = 0;
struct Matrix {
  double a[110][110];
  Matrix() { memset(a, 0, sizeof(a)); }
  void init() {
    for (int i = 0; i < now; i++)
      for (int j = 0; j < now; j++) a[i][j] = (i == j);
  }
  Matrix operator*(const Matrix &B) const {
    Matrix C;
    for (int i = 0; i < now; i++)
      for (int j = 0; j < now; j++)
        for (int k = 0; k < now; k++)
          C.a[i][j] = (C.a[i][j] + a[i][k] * B.a[k][j]);
    return C;
  }
  Matrix operator^(const long long &p) const {
    Matrix A = (*this), res;
    res.init();
    long long t = p;
    while (t) {
      if (t & 1) res = res * A;
      A = A * A;
      t >>= 1;
    }
    return res;
  }
};
void Init() {
  for (int i = 0; i < now; i++) {
    double sum = 0;
    for (int j = 1; j < now; j++) sum += p[i][j];
    for (int j = 1; j < now; j++) {
      if (sum > EPS) p[i][j] /= sum;
    }
    p[i][0] = 0;
  }
  Matrix M;
  for (int i = 0; i < now; i++)
    for (int j = 0; j < now; j++) M.a[j][i] = p[i][j];
  M = M ^ (k - 1);
  printf("%.5f\n", M.a[now - 1][0]);
}
int main() {
  memset(idx, -1, sizeof(idx));
  scanf("%d%d%d", &n, &m, &k);
  idx[0] = now++;
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    if (i > 0 && a[i]) idx[i] = now++;
  }
  for (int i = 1; i <= m; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    --u, --v;
    mp[u][v]++;
    mp[v][u]++;
  }
  gauss();
  for (int i = 0; i < n; i++) {
    if (a[i] == 1 || i == 0) {
      solve(i);
    }
  }
  Init();
}