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 <int N>
struct SMatrix {
  valarray<double> d[N];
  SMatrix(bool f = false) {
    for (int i = 0; i < N; i++) {
      d[i] = valarray<double>(N);
    }
    for (int i = 0; i < N; i++) {
      d[i] = 0.0;
    }
    if (f) {
      for (int i = 0; i < N; i++) {
        d[i][i] = 1.0;
      }
    }
  }
  valarray<double> &operator[](int p) { return d[p]; }
  const valarray<double> &operator[](int p) const { return d[p]; }
  SMatrix &operator=(const SMatrix &other) {
    for (int i = 0; i < N; i++) {
      d[i] = other[i];
    }
    return *this;
  }
  SMatrix operator+(const SMatrix &right) {
    SMatrix res(N);
    for (int i = 0; i < N; i++) {
      res[i] = d[i] + right[i];
    }
    return res;
  }
  SMatrix operator*(const SMatrix &right) {
    SMatrix<N> res, r;
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        r[i][j] = right[j][i];
      }
    }
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        res[i][j] = (d[i] * r[j]).sum();
      }
    }
    return res;
  }
  void operator*=(const SMatrix &right) {
    SMatrix buf, r;
    for (int i = 0; i < N; i++) {
      buf[i] = d[i];
    }
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        r[i][j] = right[j][i];
      }
    }
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        d[i][j] = (buf[i] * r[j]).sum();
      }
    }
  }
  SMatrix operator*(const double x) {
    SMatrix res(N);
    for (int i = 0; i < N; i++) {
      res[i] = d[i] * x;
    }
    return res;
  }
  SMatrix pow(long long p) {
    SMatrix res(true), buf = *this;
    while (p != 0) {
      if (p % 2) {
        res *= buf;
      }
      p /= 2;
      buf *= buf;
    }
    return res;
  }
  void mulL(int i, double x) { d[i] *= x; }
  void excL(int i, int j) { swap(d[i], d[j]); }
  void addL(int i, int j, double x) { d[i] += d[j] * x; }
  int inverse() {
    SMatrix r(true);
    for (int i = 0; i < N; i++) {
      if (d[i][i] == 0) {
        int j;
        for (j = i + 1; j < N; j++) {
          if (d[i][j] != 0) {
            r.excL(i, j);
            excL(i, j);
            break;
          }
        }
        if (j == N) return i;
      }
      r.mulL(i, 1 / d[i][i]);
      mulL(i, 1 / d[i][i]);
      for (int j = 0; j < N; j++) {
        if (i == j) continue;
        r.addL(j, i, -d[j][i]);
        addL(j, i, -d[j][i]);
      }
    }
    *this = r;
    return N;
  }
};
const int MN = 512;
int main() {
  int n, m;
  long long k;
  cin >> n >> m >> k;
  SMatrix<MN> A, B, C, D(true), E(true), nE(true);
  nE = nE * (-1);
  int d[MN];
  for (int i = 0; i < n; i++) {
    cin >> d[i];
  }
  int count[MN] = {};
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    if (!d[a]) {
      A[a][b] += 1;
    } else {
      B[a][b] += 1;
    }
    if (!d[b]) {
      A[b][a] += 1;
    } else {
      B[b][a] += 1;
    }
    count[a]++;
    count[b]++;
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      A[i][j] /= count[i];
      B[i][j] /= count[i];
    }
  }
  A = E + (A * (-1));
  A.inverse();
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (!d[i] && !d[j]) {
        A[i][j] = 0.0;
      }
    }
  }
  vector<int> v;
  for (int i = 0; i < n; i++) {
    if (d[i]) v.push_back(i);
  }
  int a = v.size();
  SMatrix<101> F;
  C = B * A;
  for (int i = 0; i < a; i++) {
    for (int j = 0; j < a; j++) {
      F[i][j] = C[v[i]][v[j]];
    }
  }
  F = F.pow(k - 2);
  for (int i = 0; i < a; i++) {
    for (int j = 0; j < a; j++) {
      D[v[i]][v[j]] = F[i][j];
    }
  }
  D = A * D;
  printf("%.20f\n", D[0][n - 1]);
  return 0;
}