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;
char string_in_buffer[(int)260];
void fast_scan(int &first) { scanf("%d", &first); }
void fast_scan(long long &first) { scanf("%lld", &first); }
void fast_scan(unsigned long long &first) { scanf("%llu", &first); }
void fast_scan(double &first) { scanf("%lf", &first); }
void fast_scan(long double &first) { scanf("%Lf", &first); }
void fast_scan(char &first) {
  scanf("%c", &first);
  if (first == '\n') {
    fast_scan(first);
  }
}
void fast_scan(string &first) {
  scanf("%s", string_in_buffer);
  first = string(string_in_buffer);
}
template <class TFirst, class TSecond>
void fast_scan(pair<TFirst, TSecond> &p) {
  fast_scan(p.first);
  fast_scan(p.second);
}
template <class T>
void fast_scan(vector<T> &v) {
  for (auto &first : v) fast_scan(first);
}
void fast_print(const int &first) { printf("%d", first); }
void fast_print(const unsigned int &first) { printf("%u", first); }
void fast_print(const long long &first) { printf("%lld", first); }
void fast_print(const unsigned long long &first) { printf("%llu", first); }
void fast_print(const double &first) { printf("%.15lf", first); }
void fast_print(const float &first) { printf("%.15f", first); }
void fast_print(const long double &first) { printf("%.15Lf", first); }
void fast_print(const char &first) { printf("%c", first); };
void fast_print(const string &first) { printf("%s", first.c_str()); }
void fast_print(const char v[]) { fast_print((string)v); }
template <class TFirst, class TSecond>
void fast_print(const pair<TFirst, TSecond> &p) {
  fast_print(p.first);
  fast_print(' ');
  fast_print(p.second);
}
template <class T>
void fast_print(const vector<T> &v) {
  if (v.empty()) return;
  fast_print(v[0]);
  for (int i = 1; i < v.size(); i++) {
    fast_print(' ');
    fast_print(v[i]);
  }
}
template <class T>
void fast_print(const vector<vector<T>> &v) {
  if (v.empty()) return;
  fast_print(v[0]);
  for (int i = 1; i < v.size(); i++) {
    fast_print('\n');
    fast_print(v[i]);
  }
}
template <class T>
void fast_print(const T &v) {
  for (const auto &first : v) {
    fast_print(first);
    fast_print(' ');
  }
}
using namespace std;
namespace smart_io {
string print_start = "";
string sep = " ";
bool first_print = false;
void precall_print() {
  fast_print(print_start);
  print_start = "\n";
  first_print = true;
}
void _print(deque<string>) {}
template <class T, class... Args>
void _print(deque<string> names, T elem, Args... args) {
  if (!first_print) {
    fast_print("\n");
  } else {
    first_print = false;
  }
  fast_print(names.front());
  fast_print(" = ");
  fast_print(elem);
  names.pop_front();
  _print(names, args...);
}
}  // namespace smart_io
template <class T>
ostream &operator,(ostream &os, const T &object) {
  if (!smart_io::first_print) {
    fast_print(smart_io::sep);
  } else {
    smart_io::first_print = false;
  }
  fast_print(object);
  return os;
}
template <class T>
istream &operator,(istream &is, T &object) {
  fast_scan(object);
  return is;
}
namespace typedefs {}
namespace numbers_operation {
template <class T>
T floor_mod(T a, T b) {
  if (a % b == 0) return 0;
  if (a >= 0 && b >= 0) return a % b;
  if (a <= 0 && b <= 0) return a % b;
  return abs(b) - (abs(a) % abs(b));
}
}  // namespace numbers_operation
using namespace numbers_operation;
using namespace typedefs;
int n, m, k;
vector<vector<int>> g;
vector<int> trap;
vector<int> ztraps;
int traps = 0;
vector<vector<double>> gauss(vector<vector<double>> M) {
  for (int i = 0; i < (((int)M[0].size())); i++) {
    int unz = 0;
    for (int j = 0; j < (((int)M.size())); j++) {
      if (abs(M[j][i]) > abs(M[unz][i])) {
        unz = j;
      }
    }
    if (M[unz][i] == 0) continue;
    double cor = M[unz][i];
    for (int j = 0; j < (((int)M[0].size())); j++) {
      M[unz][j] /= cor;
    }
    for (int j = 0; j < (((int)M.size())); j++) {
      double coef = M[j][i] / M[unz][i];
      for (int k = 0; k < (((int)M[0].size())); k++) {
        M[j][k] -= coef * M[unz][k];
      }
    }
  }
  return M;
}
vector<vector<double>> merge(vector<vector<double>> A,
                             vector<vector<double>> B) {
  vector<vector<double>> C(traps, vector<double>(traps));
  for (int st = 0; st < (traps); st++) {
    for (int inter = 0; inter < (traps); inter++) {
      for (int end = 0; end < (traps); end++) {
        C[st][end] += A[st][inter] * B[inter][end];
      }
    }
  }
  return C;
}
vector<double> operator*(vector<double> v, double d) {
  for (double &first : v) {
    first *= d;
  }
  return v;
}
vector<double> operator+(vector<double> a, vector<double> b) {
  assert(((int)a.size()) == ((int)b.size()));
  for (int i = 0; i < (((int)b.size())); i++) {
    a[i] += b[i];
  }
  return a;
}
vector<double> operator-(vector<double> a, vector<double> b) {
  return a + (b * -1);
}
vector<vector<double>> get_first() {
  vector<vector<double>> prob(n, vector<double>(n));
  for (int i = 0; i < n; i++) {
    if (trap[i]) {
      prob[i][i] = 1;
    } else {
      for (int j : g[i]) {
        prob[i][j] += 1.0 / ((int)g[i].size());
      }
    }
  }
  vector<vector<double>> R(n, vector<double>(n));
  for (int i = 0; i < n; i++) {
    prob[i][i] -= 1;
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (trap[j]) {
        R[i][j] = -prob[i][j];
        prob[i][j] = 0;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    if (trap[i]) continue;
    for (int j = i + 1; j < n; j++) {
      if (abs(prob[j][i]) > abs(prob[i][i])) {
        swap(prob[j], prob[i]);
        swap(R[j], R[i]);
      }
    }
    for (int j = i + 1; j < n; j++) {
      double cor = prob[j][i] / prob[i][i];
      for (int k = 0; k < n; k++) {
        prob[j][k] -= cor * prob[i][k];
        R[j][k] -= cor * R[i][k];
      }
    }
  }
  vector<vector<double>> final(n, vector<double>(n));
  for (int i = n - 1; i > -1; i--) {
    if (trap[i]) continue;
    for (int j = 0; j < n; j++) {
      R[i][j] /= prob[i][i];
    }
    prob[i][i] = 1;
    for (int j = 0; j < i; j++) {
      for (int k = 0; k < n; k++) {
        R[j][k] -= prob[j][i] * R[i][k];
      }
      prob[j][i] = 0;
    }
  }
  vector<vector<double>> next(n, vector<double>(n));
  for (int i = 0; i < n; i++) {
    if (trap[i]) {
      R[i] = vector<double>(n, 0);
      R[i][i] = 1;
    }
    double c = 1;
    for (int j = 0; j < n; j++) {
      c -= R[i][j];
    }
  }
  return R;
}
vector<vector<double>> one;
vector<vector<double>> fast_pow(int k) {
  if (k == 1) {
    if (!one.empty()) return one;
    vector<vector<double>> F = get_first();
    vector<vector<double>> P(traps, vector<double>(traps));
    for (int i = 0; i < (traps); i++) {
      for (int j = 0; j < (traps); j++) {
        for (int sub : g[ztraps[i]]) {
          P[i][j] += F[sub][ztraps[j]];
        }
        P[i][j] /= ((int)g[ztraps[i]].size());
      }
    }
    return one = P;
  } else {
    if (k % 2 == 0) {
      vector<vector<double>> first = fast_pow(k / 2);
      return merge(first, first);
    } else {
      vector<vector<double>> first = fast_pow(k - 1);
      return merge(first, fast_pow(1));
    }
  }
}
signed main(signed argc, char *argv[]) {
  cin, n, m, k;
  trap.resize(n);
  g.resize(n);
  cin, trap;
  for (int i = 0; i < (n); i++) {
    traps += trap[i];
    if (trap[i]) {
      ztraps.push_back(i);
    }
  }
  for (int i = 0; i < (m); i++) {
    int a, b;
    cin, a, b;
    a--;
    b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  if (k == 2) {
    vector<vector<double>> F = get_first();
    smart_io::precall_print();
    cout, F[0][n - 1];
  } else {
    vector<vector<double>> P = fast_pow(k - 2);
    vector<vector<double>> F = get_first();
    double rez = 0;
    for (int i = 0; i < (traps); i++) {
      rez += F[0][ztraps[i]] * P[i][traps - 1];
    }
    smart_io::precall_print();
    cout, rez;
  }
}