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:16777216")
using namespace std;
const int inf = 0x3f3f3f3f;
const long long inf64 = 0x3f3f3f3f3f3f3f3fLL;
const double eps = 1e-6;
template <typename A, typename B>
ostream& operator<<(ostream& os, const pair<A, B>& p) {
  return os << p.first << "," << p.second;
}
template <typename A>
ostream& operator<<(ostream& os, const vector<A>& v) {
  for (int i = 0; i < v.size(); i++) {
    os << v[i] << ";";
  }
  return os;
}
template <typename A>
ostream& operator<<(ostream& os, const set<A>& v) {
  for (typename set<A>::const_iterator it = v.begin(); it != v.end(); ++it) {
    os << *it << ";";
  }
  return os;
}
template <typename A, typename B>
ostream& operator<<(ostream& os, const map<A, B>& v) {
  for (typename map<A, B>::const_iterator it = v.begin(); it != v.end(); ++it) {
    os << it->first << "=" << it->second << ";";
  }
  return os;
}
const int maxn = 509;
const int maxt = 104;
int trap[maxn];
int a[maxn][maxn];
vector<int> g[maxn];
double b[maxn][maxn + maxt];
double d[maxt][maxt];
double rd[maxt][maxt];
double tmp[maxt][maxt];
void mul(const double a[maxt][maxt], const double b[maxt][maxt],
         double r[maxt][maxt]) {
  for (int i = 0; i < maxt; i++) {
    for (int j = 0; j < maxt; j++) {
      tmp[i][j] = 0;
      for (int k = 0; k < maxt; k++) {
        tmp[i][j] += a[i][k] * b[k][j];
      }
    }
  }
  for (int i = 0; i < maxt; i++) {
    for (int j = 0; j < maxt; j++) {
      r[i][j] = tmp[i][j];
    }
  }
}
void pw(double a[maxt][maxt], double r[maxt][maxt], int p) {
  for (int i = 0; i < maxt; i++) {
    for (int j = 0; j < maxt; j++) {
      r[i][j] = 0;
    }
    r[i][i] = 1;
  }
  for (; p; p >>= 1) {
    if (p & 1) {
      mul(r, a, r);
    }
    mul(a, a, a);
  }
}
int trapindex[maxn];
vector<double> getrowsum(int h, int w) {
  vector<double> ans(h);
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      ans[i] += b[i][j];
    }
  }
  return ans;
}
vector<double> getcolsum(int h, int w) {
  vector<double> ans(w);
  for (int i = 0; i < w; i++) {
    for (int j = 0; j < h; j++) {
      ans[i] += b[j][i];
    }
  }
  return ans;
}
double getsum(int h, int w) {
  double ans = 0;
  for (int i = 0; i < w; i++) {
    for (int j = 0; j < h; j++) {
      ans += b[j][i];
    }
  }
  return ans;
}
vector<double> getabsrowsum(int h, int w) {
  vector<double> ans(h);
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      ans[i] += abs(b[i][j]);
    }
  }
  return ans;
}
vector<double> getabscolsum(int h, int w) {
  vector<double> ans(w);
  for (int i = 0; i < w; i++) {
    for (int j = 0; j < h; j++) {
      ans[i] += abs(b[j][i]);
    }
  }
  return ans;
}
double getabssum(int h, int w) {
  double ans = 0;
  for (int i = 0; i < w; i++) {
    for (int j = 0; j < h; j++) {
      ans += abs(b[j][i]);
    }
  }
  return ans;
}
int main() {
  int n, m, k;
  cin >> n >> m >> k;
  assert(n < maxn);
  for (int i = 0; i < n; i++) {
    cin >> trap[i];
  }
  vector<int> trapvectices;
  for (int i = 0; i < n; i++)
    if (trap[i]) {
      trapvectices.push_back(i);
      trapindex[i] = trapvectices.size() - 1;
    }
  int r = trapvectices.size();
  assert(r < maxt);
  for (int i = 0; i < m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    x--;
    y--;
    a[x][y]++;
    a[y][x]++;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  vector<double> initprob;
  for (int i = 0; i < n; i++) {
    b[i][i] = 1;
    for (int j = 0; j < n; j++)
      if (j != i) {
        if (trap[j]) {
          b[i][n + trapindex[j]] = a[i][j] / double(g[i].size());
        } else {
          b[i][j] = -a[i][j] / double(g[i].size());
        }
      }
  }
  int row = 0;
  for (int col = 0; col < n; col++) {
    int best = -1;
    for (int i = row; i < n; i++) {
      if (best < 0 || abs(b[i][col]) > abs(b[best][col])) {
        best = i;
      }
    }
    if (best < 0 || abs(b[best][col]) < eps) {
      continue;
    }
    if (best != row) {
      for (int i = 0; i < n + r; i++) {
        swap(b[best][i], b[row][i]);
      }
    }
    double q = b[row][col];
    for (int i = 0; i < n + r; i++) {
      b[row][i] /= q;
    }
    for (int i = row + 1; i < n; i++)
      if (i != row) {
        double q = b[i][col];
        for (int j = 0; j < n + r; j++) {
          b[i][j] -= q * b[row][j];
        }
      }
    row++;
  }
  for (int i = 0; i < row; i++) {
    for (int j = 0; j < i; j++) {
      double q = b[j][i];
      for (int k = 0; k < n + r; k++) {
        b[j][k] -= q * b[i][k];
      }
    }
  }
  assert(row == n);
  for (int k = 0; k < r; k++) {
    initprob.push_back(b[0][n + k]);
  }
  for (int i = 0; i < trapvectices.size(); i++) {
    int w = trapvectices[i];
    for (int k = 0; k < r; k++) {
      d[i][k] = b[w][n + k];
    }
  }
  auto res = initprob;
  int pp = k - 2;
  for (; pp; pp >>= 1) {
    if (pp & 1) {
      for (int i = 0; i < r; i++) {
        tmp[0][i] = 0;
        for (int j = 0; j < r; j++) {
          tmp[0][i] += res[j] * d[j][i];
        }
      }
      for (int i = 0; i < r; i++) {
        res[i] = tmp[0][i];
      }
    }
    mul(d, d, d);
  }
  printf("%.14lf\n", double(res[r - 1]));
  return 0;
}