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;
template <class T>
bool uax(T& a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
bool uin(T& a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
const int MOD = 1000000007;
const int inf = 1e9 + 100500;
const double pi = acosl(-1.0);
const double eps = 1e-9;
const int N = 501;
double a[N][N];
double dv[N];
double d[N][N];
int g[N][N];
int s[N];
bool f[N];
int n;
void sqr(double a[N][N], int n) {
  static double ta[N][N], tb[N][N];
  for (int i = 0; i < (int)(n); ++i)
    for (int j = 0; j < (int)(n); ++j) ta[i][j] = tb[j][i] = a[i][j];
  for (int i = 0; i < (int)(n); ++i)
    for (int j = 0; j < (int)(n); ++j) a[i][j] = 0;
  for (int i = 0; i < (int)(n); ++i)
    for (int j = 0; j < (int)(n); ++j)
      for (int k = 0; k < (int)(n); ++k) a[i][j] += ta[i][k] * tb[j][k];
}
void mulpow(int n, double d[N][N], double dv[N], int k) {
  static double tv[N];
  while (k) {
    if (k & 1) {
      for (int i = 0; i < (int)(n); ++i) tv[i] = 0;
      for (int i = 0; i < (int)(n); ++i)
        for (int j = 0; j < (int)(n); ++j) tv[i] += dv[j] * d[i][j];
      for (int i = 0; i < (int)(n); ++i) dv[i] = tv[i];
    }
    if (k /= 2) {
      sqr(d, n);
    }
  }
}
void solve() {
  int m, k;
  n = 500;
  m = 100000;
  k = 1000000000;
  cin >> n >> m >> k;
  for (int i = 0; i < (int)(n); ++i) {
    f[i] = (rand() % 4 == 0);
    cin >> f[i];
  }
  f[0] = 0;
  f[n - 1] = 1;
  for (int i = 0; i < (int)(m); ++i) {
    int a, b;
    a = rand() % n;
    b = rand() % n;
    if (b == a) b = (a + 1) % n;
    cin >> a >> b;
    --a;
    --b;
    g[a][b] += 1;
    g[b][a] += 1;
    s[a] += 1;
    s[b] += 1;
  }
  for (int i = 0; i < (int)(n); ++i)
    if (!f[i]) {
      for (int j = 0; j < (int)(n); ++j) a[i][j] = (double)g[i][j] / s[i];
    } else {
      a[i][i] = (double)1.0;
    }
  for (int t = 0; t < (int)(17); ++t) sqr(a, n);
  vector<int> fn(n);
  int cntf = 0;
  for (int i = 0; i < (int)(n); ++i)
    if (f[i])
      fn[i] = cntf++;
    else
      fn[i] = -1;
  for (int i = 0; i < (int)(n); ++i)
    if (fn[i] != -1)
      for (int j = 0; j < (int)(n); ++j)
        if (fn[j] != -1) {
          for (int k = 0; k < (int)(n); ++k)
            if (fn[k] == -1) d[fn[i]][fn[j]] += g[i][k] * a[k][j] / s[i];
          d[fn[i]][fn[j]] += (double)g[i][j] / s[i];
        }
  for (int i = 0; i < (int)(cntf); ++i) dv[i] = 0;
  dv[fn[n - 1]] = 1;
  mulpow(cntf, d, dv, k - 2);
  double ans = 0;
  for (int i = 0; i < (int)(n); ++i)
    if (f[i]) ans += a[0][i] * dv[fn[i]];
  cout << ans << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed;
  cout.precision(15);
  cerr << fixed;
  cerr.precision(15);
  solve();
  return 0;
}