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;
vector<vector<long double> > mul(vector<vector<long double> >& a,
                                 vector<vector<long double> >& b) {
  vector<vector<long double> > m(a.size(), vector<long double>(a.size(), 0.));
  for (int i = 0; i < a.size(); i++)
    for (int j = 0; j < a[0].size(); j++)
      for (int k = 0; k < a.size(); k++) m[i][j] += a[i][k] * b[k][j];
  return m;
}
void print(vector<vector<long double> >& a) {
  for (int i = 0; i < a.size(); i++)
    for (int j = 0; j < a[i].size(); j++)
      cout << a[i][j] << " \n"[a[0].size() - 1 == j];
  cout << "\n";
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m, k, t = 0;
  cin >> n >> m >> k;
  vector<int> deg(n, 0), trap, id(n, -1);
  for (int i = 0, a; i < n; i++) {
    cin >> a;
    if (a) trap.push_back(i), id[i] = t++;
  }
  vector<vector<int> > g(n, vector<int>(n, 0));
  for (int i = 0, u, v; i < m; i++) {
    cin >> u >> v;
    deg[--u]++, deg[--v]++;
    g[u][v]++, g[v][u]++;
  }
  vector<vector<long double> > eq(n, vector<long double>(n + t, 0));
  for (int i = 0; i < n; i++) {
    if (id[i] == -1) {
      eq[i][i] = -1;
      for (int j = 0; j < n; j++)
        if (j != i) eq[i][j] = ((long double)g[i][j]) / ((long double)deg[i]);
    } else
      eq[i][i] = eq[i][n + id[i]] = 1.;
  }
  for (int i = 0; i < n; i++) {
    int pos = i;
    for (int j = i + 1; j < n; j++)
      if (abs(eq[pos][i]) < abs(eq[j][i])) pos = j;
    swap(eq[i], eq[pos]);
    for (int j = i + 1; j < n + t; j++) eq[i][j] /= eq[i][i];
    eq[i][i] = 1.;
    for (int e = i + 1; e < n; e++) {
      for (int j = i + 1; j < n + t; j++) eq[e][j] -= eq[i][j] * eq[e][i];
      eq[e][i] = 0;
    }
  }
  vector<vector<long double> > p(n, vector<long double>(t, 0.));
  for (int i = 0; i < t; i++)
    for (int j = n - 1; j >= 0; j--) {
      p[j][i] = eq[j][n + i];
      for (int x = j + 1; x < n; x++) p[j][i] -= eq[j][x] * p[x][i];
    }
  vector<vector<long double> > tr(t, vector<long double>(t, 0));
  for (int i = 0; i < t; i++)
    for (int j = 0; j < t; j++)
      for (int e = 0; e < n; e++)
        tr[i][j] += ((long double)g[trap[i]][e]) / ((long double)deg[trap[i]]) *
                    p[e][j];
  vector<vector<long double> > ans(t, vector<long double>(t, 0));
  for (int i = 0; i < t; i++) ans[i][i] = 1.;
  k -= 2;
  for (; k; k >>= 1, tr = mul(tr, tr))
    if (k & 1) ans = mul(ans, tr);
  long double sum = 0.;
  for (int f = 0; f < t; f++) sum += p[0][f] * ans[f][id[n - 1]];
  cout << setprecision(10) << fixed << sum << "\n";
  return 0;
}