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 <typename T>
ostream& operator<<(ostream& out, vector<T> const& a) {
  out << "[";
  for (int i = 0; i < int((a).size()); ++i) {
    if (i != 0) {
      out << ", ";
    }
    out << a[i];
  }
  out << "]";
  return out;
}
template <typename T1, typename T2>
ostream& operator<<(ostream& out, pair<T1, T2> const& p) {
  out << "(" << p.first << ", " << p.second << ")";
  return out;
}
const int N = 500;
const int M = 1e5;
const int T = 101;
struct Data {
  int n, m, k;
  bool isT[N];
  vector<pair<int, int> > ed;
  bool read() {
    if (!(cin >> n >> m >> k)) {
      return false;
    }
    for (int i = 0; i < n; ++i) {
      cin >> isT[i];
    }
    for (int i = 0; i < m; ++i) {
      int u, v;
      cin >> u >> v;
      --u, --v;
      ed.push_back(make_pair(u, v));
    }
    return true;
  }
  long double ans;
  void write() {
    cout.precision(20);
    cout.setf(ios::fixed | ios::showpoint);
    cout << ans << "\n";
  }
  virtual void solve() {}
  virtual void clear() { *this = Data(); }
};
struct Matrix {
  int n;
  long double a[T][T];
  Matrix() {}
  Matrix(int n, long double x) : n(n) {
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < n; ++j) {
        a[i][j] = 0;
      }
      a[i][i] = x;
    }
  }
  long double& operator()(int i, int j) { return a[i][j]; }
  long double operator()(int i, int j) const { return a[i][j]; }
};
Matrix operator*(Matrix const& a, Matrix const& b) {
  int n = a.n;
  Matrix c(n, 0);
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      for (int k = 0; k < n; ++k) {
        c(i, j) += a(i, k) * b(k, j);
      }
    }
  }
  return c;
}
Matrix pow(Matrix const& a, int n) {
  Matrix r(a.n, 1), c(a);
  while (n > 0) {
    if (n & 1) {
      r = r * c;
    }
    c = c * c;
    n /= 2;
  }
  return r;
}
vector<long double> operator*(Matrix const& a, vector<long double> const& b) {
  int n = a.n;
  vector<long double> c(n);
  for (int i = 0; i < n; ++i) {
    c[i] = 0;
    for (int j = 0; j < n; ++j) {
      c[i] += a(i, j) * b[j];
    }
  }
  return c;
}
ostream& operator<<(ostream& out, Matrix const& a) {
  int n = a.n;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      out << a(i, j) << " ";
    }
    out << "\n";
  }
  return out;
}
struct Solution : Data {
  long double A[N][N], b[N], afterFirstB[N], c[N];
  long double invA[N][N];
  Matrix C;
  vector<int> g[N];
  vector<int> trips;
  void printMatrix(long double A[N][N]) {
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < n; ++j) {
        cerr << A[i][j] << " ";
      }
      cerr << "\n";
    }
    cerr << "\n";
  }
  void inv(long double A[N][N], long double B[N][N]) {
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < n; ++j) {
        B[i][j] = 0;
      }
      B[i][i] = 1;
    }
    for (int k = 0; k < n; ++k) {
      int pv = k;
      for (int i = k + 1; i < n; ++i) {
        if (fabsl(A[i][k]) > fabsl(A[pv][k])) {
          pv = i;
        }
      }
      for (int j = 0; j < n; ++j) {
        swap(A[k][j], A[pv][j]);
        swap(B[k][j], B[pv][j]);
      }
      long double e = A[k][k];
      for (int j = 0; j < n; ++j) {
        A[k][j] /= e;
        B[k][j] /= e;
      }
      for (int i = k + 1; i < n; ++i) {
        e = A[i][k];
        for (int j = 0; j < n; ++j) {
          A[i][j] -= A[k][j] * e;
          B[i][j] -= B[k][j] * e;
        }
      }
    }
    for (int k = n - 1; k >= 0; --k) {
      for (int i = 0; i < k; ++i) {
        long double e = A[i][k];
        for (int j = 0; j < n; ++j) {
          A[i][j] -= A[k][j] * e;
          B[i][j] -= B[k][j] * e;
        }
      }
    }
  }
  void calcA() {
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < n; ++j) {
        A[i][j] = 0;
      }
      A[i][i] = 1.;
      for (int j = 0; j < int((g[i]).size()); ++j) {
        int v = g[i][j];
        if (isT[v]) {
          continue;
        }
        A[i][v] -= 1.L / int((g[v]).size());
      }
    }
    inv(A, invA);
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < n; ++j) {
        A[i][j] = invA[i][j];
      }
    }
  }
  void calcB(int u, long double b[]) {
    fill(b, b + n, 0);
    for (int i = 0; i < int((g[u]).size()); ++i) {
      int v = g[u][i];
      b[v] += 1.L / int((g[u]).size());
    }
  }
  void mul(long double a[N][N], long double b[N], long double c[N]) {
    for (int i = 0; i < n; ++i) {
      c[i] = 0;
      for (int j = 0; j < n; ++j) {
        c[i] += a[i][j] * b[j];
      }
    }
  }
  void printVector(long double b[N]) {
    for (int i = 0; i < n; ++i) {
      cerr << b[i] << " ";
    }
    cerr << endl;
  }
  void solve() {
    for (int i = 0; i < m; ++i) {
      int u = ed[i].first, v = ed[i].second;
      g[u].push_back(v);
      g[v].push_back(u);
    }
    calcA();
    calcB(0, b);
    mul(A, b, afterFirstB);
    for (int i = 0; i < n; ++i) {
      if (isT[i]) {
        trips.push_back(i);
      }
    }
    int tc = int((trips).size());
    vector<long double> bc;
    for (int i = 0; i < tc; ++i) {
      bc.push_back(afterFirstB[trips[i]]);
    }
    C = Matrix(tc, 0);
    for (int i = 0; i < tc; ++i) {
      calcB(trips[i], b);
      mul(A, b, c);
      for (int j = 0; j < tc; ++j) {
        C(j, i) = c[trips[j]];
      }
    }
    bc = pow(C, k - 2) * bc;
    ans = bc[tc - 1];
  }
  Solution() {}
  Solution(Data d) : Data(d) {}
  void clear() { *this = Solution(); }
};
Solution sol;
int main() {
  sol.read();
  sol.solve();
  sol.write();
  return 0;
}