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>
#pragma comment(linker, "/STACK:256000000")
using namespace std;
const long double PI = 3.14159265358979323846;
const long double gammama = 0.57721566490153286060;
const long double eps = 1e-5;
const int INF = 1000 * 1000 * 1000 + 1;
const long long LINF = (long long)1000 * 1000 * 1000 * 1000 * 1000 * 1000;
const int mod = 1000 * 1000 * 1000 + 9;
const long long N = 300100;
void print(vector<vector<double> > a, vector<vector<double> > b) {
  for (int i = 0; i < a.size(); ++i) {
    for (int j = 0; j < a[i].size(); ++j) {
      printf("%0.2f ", a[i][j]);
    }
    cout << "\t";
    for (int j = 0; j < b[i].size(); ++j) printf("%0.2f ", b[i][j]);
    cout << "\n";
  }
  cout << "\n";
}
vector<vector<double> > gauss(vector<vector<double> > a,
                              vector<vector<double> > b) {
  int n = a.size(), m = b[0].size();
  for (int i = 0; i < n; ++i) {
    double M = abs(a[i][i]);
    int ind = i;
    for (int j = i; j < n; ++j) {
      if (abs(a[j][i]) > M) {
        M = abs(a[j][i]);
        ind = j;
      }
    }
    M = a[ind][i];
    for (int j = i; j < n; ++j) {
      swap(a[i][j], a[ind][j]);
      a[i][j] /= M;
    }
    for (int j = 0; j < m; ++j) {
      swap(b[i][j], b[ind][j]);
      b[i][j] /= M;
    }
    for (int r = 0; r < n; ++r) {
      if (r == i) continue;
      double d = a[r][i];
      for (int j = i; j < n; ++j) {
        a[r][j] -= d * a[i][j];
      }
      for (int j = 0; j < m; ++j) {
        b[r][j] -= d * b[i][j];
      }
    }
  }
  return b;
}
vector<vector<double> > mult(const vector<vector<double> >& a,
                             const vector<vector<double> >& b) {
  int n = a.size();
  vector<vector<double> > res(n, vector<double>(n, 0));
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < n; ++j)
      for (int k = 0; k < n; ++k) res[i][j] += a[i][k] * b[k][j];
  return res;
}
vector<vector<double> > power(vector<vector<double> > a, int n) {
  vector<vector<double> > res(a.size(), vector<double>(a.size(), 0));
  for (int i = 0; i < res.size(); ++i) res[i][i] = 1;
  while (n) {
    if (n & 1) res = mult(res, a);
    a = mult(a, a);
    n /= 2;
  }
  return res;
}
int main() {
  int n, m, k;
  cin >> n >> m >> k;
  vector<int> trap(n);
  vector<int> trInd;
  vector<int> trId(n);
  for (int i = 0; i < n; ++i) {
    cin >> trap[i];
    if (trap[i]) {
      trId[i] = trInd.size();
      trInd.push_back(i);
    } else
      trId[i] = -1;
  }
  int numTr = trInd.size();
  vector<vector<int> > g(n, vector<int>(n, 0));
  vector<int> deg(n, 0);
  for (int i = 0; i < m; ++i) {
    int a, b;
    cin >> a >> b;
    --a, --b;
    ++deg[a], ++deg[b];
    ++g[a][b], ++g[b][a];
  }
  vector<vector<double> > ma(n, vector<double>(n, 0)),
      mb(n, vector<double>(numTr, 0));
  for (int i = 0; i < n; ++i) {
    ma[i][i] = 1;
    for (int j = 0; j < n; ++j) {
      if (trap[j]) {
        mb[i][trId[j]] = 1.0 * g[i][j] / deg[i];
      } else {
        ma[i][j] -= 1.0 * g[i][j] / deg[i];
      }
    }
  }
  vector<vector<double> > mc = gauss(ma, mb);
  vector<double> v0 = mc[0];
  vector<vector<double> > mp(numTr, vector<double>(numTr));
  for (int i = 0; i < trInd.size(); ++i) mp[i] = mc[trInd[i]];
  for (int i = 0; i < mp.size(); ++i)
    for (int j = i + 1; j < mp.size(); ++j) swap(mp[i][j], mp[j][i]);
  vector<vector<double> > mtr = power(mp, k - 2);
  double res = 0;
  for (int i = 0; i < v0.size(); ++i) res += mtr[numTr - 1][i] * v0[i];
  printf("%0.10f\n", res);
  return 0;
}