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 iinf = 1e9 + 7;
const long long linf = 1ll << 60;
const double dinf = 1e60;
template <typename T>
inline void scf(T &x) {
  bool f = 0;
  x = 0;
  char c = getchar();
  while ((c < '0' || c > '9') && c != '-') c = getchar();
  if (c == '-') {
    f = 1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = x * 10 + c - '0';
    c = getchar();
  }
  if (f) x = -x;
  return;
}
template <typename T1, typename T2>
void scf(T1 &x, T2 &y) {
  scf(x);
  return scf(y);
}
template <typename T1, typename T2, typename T3>
void scf(T1 &x, T2 &y, T3 &z) {
  scf(x);
  scf(y);
  return scf(z);
}
template <typename T1, typename T2, typename T3, typename T4>
void scf(T1 &x, T2 &y, T3 &z, T4 &w) {
  scf(x);
  scf(y);
  scf(z);
  return scf(w);
}
inline char mygetchar() {
  char c = getchar();
  while (c == ' ' || c == '\n') c = getchar();
  return c;
}
template <typename T>
void chkmax(T &x, const T &y) {
  if (y > x) x = y;
  return;
}
template <typename T>
void chkmin(T &x, const T &y) {
  if (y < x) x = y;
  return;
}
const int N = 510;
const int M = 110;
int n, m, k;
double A[N][N + N];
double w[M][M], p[N][N];
bool f[N];
vector<int> trap;
double beg[N];
void calc_w() {
  for (int i = (1); i <= (n); ++i) {
    A[i][i] = 1.0;
    if (!f[i])
      for (int j = (1); j <= (n); ++j)
        if (i != j) A[i][j] = -p[i][j];
    A[i][i + n] = 1.0;
  }
  for (int row = 1, col = 1; row <= n; ++row) {
    int pivot = row;
    for (int i = (row + 1); i <= (n); ++i)
      if (fabs(A[i][col]) > fabs(A[pivot][col])) pivot = i;
    if (fabs(A[pivot][col]) <= 1e-6) continue;
    swap(A[pivot], A[row]);
    double foo = A[row][col];
    for (int i = (1); i <= (n + n); ++i) A[row][i] /= foo;
    for (int i = (1); i <= (n); ++i)
      if (i != row) {
        foo = A[i][col];
        for (int j = (1); j <= (n + n); ++j) A[i][j] -= foo * A[row][j];
      }
    ++col;
  }
  for (int i = 0; i < (m); ++i)
    for (int j = 0; j < (m); ++j) {
      int u = trap[i], v = trap[j];
      for (int k = (1); k <= (n); ++k) w[i][j] += p[u][k] * A[k][v + n];
    }
  for (int i = 0; i < (m); ++i) beg[i] = A[1][trap[i] + n];
  return;
}
void TZL() {
  static int g[N][N], deg[N];
  memset((g), (0), sizeof((g)));
  memset((deg), (0), sizeof((deg)));
  scf(n, m, k);
  for (int i = (1); i <= (n); ++i) {
    scf(f[i]);
    if (f[i]) trap.push_back(i);
  }
  for (int i = 0; i < (m); ++i) {
    int u, v;
    scf(u, v);
    g[u][v]++;
    g[v][u]++;
    deg[u]++;
    deg[v]++;
  }
  m = (int)trap.size();
  for (int i = (1); i <= (n); ++i)
    for (int j = (1); j <= (n); ++j) p[i][j] = (1.0 * g[i][j]) / (1.0 * deg[i]);
  return calc_w();
}
struct mat {
  double num[M][M];
  mat() { memset((num), (0), sizeof((num))); }
  mat(int x) {
    memset((num), (0), sizeof((num)));
    for (int i = 0; i < (M); ++i) num[i][i] = x;
  }
  mat(double a[][M]) {
    for (int i = 0; i < (M); ++i)
      for (int j = 0; j < (M); ++j) num[i][j] = a[i][j];
  }
  double &operator()(int i, int j) { return num[i][j]; }
  double operator()(int i, int j) const { return num[i][j]; }
  friend mat operator*(const mat &a, const mat &b) {
    mat c;
    for (int i = 0; i < (M); ++i)
      for (int j = 0; j < (M); ++j)
        for (int k = 0; k < (M); ++k) c(i, j) += a(i, k) * b(k, j);
    return c;
  }
} g;
mat kiss_me(mat a, int n) {
  mat ret = mat(1);
  while (n) {
    if (n & 1) ret = ret * a;
    a = a * a;
    n >>= 1;
  }
  return ret;
}
void RANK1() {
  g = mat(w);
  g = kiss_me(g, k - 2);
  double ans = 0.0;
  for (int i = 0; i < (m); ++i) ans += beg[i] * g(i, m - 1);
  printf("%.12f\n", ans);
  return;
}
int main() {
  TZL();
  RANK1();
  return 0;
}