#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(X) (X).begin(),(X).end()
#define pb emplace_back
using namespace std;
typedef long double Data;
typedef vector<Data> Array;
typedef vector<Array> Matrix;
typedef map<int, Data> SpArray;
typedef map<int, SpArray> SpMatrix;
const Data eps = 1e-15;
bool is_zero(Data dat) { return (abs(dat) < eps); }
Array operator+(const Array &lhs, const Array &rhs) {
  Array res = lhs;
  REP(i,rhs.size()) res[i] = res[i] + rhs[i];
  return res;
}
Array operator*(Data scalar, const Array &rhs) {
  Array res(rhs.size());
  REP(i,rhs.size())
    res[i] = scalar * rhs[i];
  return res;
}
Data norm(const Array &a) {
  return inner_product(begin(a),end(a),begin(a),Data(0));
}
Matrix mult(const SpMatrix &lhs, const SpMatrix &rhs, int row, int col) {
  Matrix res(row, Array(col, 0));
  for (auto& l:lhs) {
    for (auto& v:l.second){
      int i=l.first;
      int k=v.first;
      if (!rhs.count(k)) continue;
      for (auto& r:rhs.find(k)->second){
        int j=r.first;
        res[i][j] = res[i][j] + v.second * r.second;
      }
    }
  }
  return res;
}
Array mult(const SpMatrix &lhs, const Array &rhs, int len) {
  Array res(len, 0);
  for (auto& l:lhs) {
    int i = l.first;
    for (auto& v:l.second)
      res[i] = res[i] + v.second * rhs[v.first];
  }
  return res;
}
SpMatrix transpose(const SpMatrix &A) {
  SpMatrix res;
  for (auto& l:A) for (auto& p:l.second) res[p.first][l.first] = p.second;
  return res;
}
Array CG_method_impl(const SpMatrix& A, const SpMatrix& A_t, const Array& b) {
  Array r_old = b;
  Array p_old = r_old;
  Array x(b.size(), Data(0));
  while(true) {
    Array Axp = mult(A, p_old, p_old.size());
    Data alpha = norm(r_old) / norm(Axp); // p^T * A^T * A * p = (A*p)^T * (A*p) = norm(A*p)
    x = x + alpha * p_old;
    Array r_new = r_old + -alpha * mult(A_t, mult(A, p_old, p_old.size()), p_old.size());
    if (all_of(begin(r_new),end(r_new),is_zero)) break;
    Data beta = norm(r_new) / norm(r_old);
    Array p_new = r_new + beta * p_old;
    r_new.swap(r_old);
    p_new.swap(p_old);
  }
  return x;
}
// solve System of linear equations
Array CG_method(const SpMatrix& A, const SpArray& b, int n) {
  SpMatrix A_t = transpose(A);
  SpMatrix B; B[0] = b;
  Array b_prime = mult(B, A, 1, n)[0]; //A^T * b^T = (b * A)^T
  return CG_method_impl(A, A_t, b_prime); // A^T * A * x^T = A^T * b^T
}
int main() {
  int N, S, T;
  while (cin >> N >> S >> T, N) {
    --S; --T;
    vector<int> Q(N);
    REP(i,N) cin >> Q[i];
    vector<vector<int>> mat(N, vector<int>(N));
    REP(i,N) REP(j,N) cin >> mat[i][j];
    REP(i,N) REP(j,N) if (i != j && mat[i][j] == 0) mat[i][j] = 1000000000;
    vector<vector<int>> dist = mat;
    REP(k,N) REP(i,N) REP(j,N)
      dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
    if (dist[S][T] == 1000000000) { cout << "impossible" << endl; }
    Matrix A(N, Array(N));
    REP(i,N) {
      vector<int> v;
      REP(j,N) {
        if (Q[i] == 0 && i != T && i != j && mat[i][j] < 1000000000)
          v.push_back(j);
        if (Q[i] && i != j && dist[i][T] == dist[j][T] + mat[i][j])
          v.push_back(j);
      }
      for (int j : v) A[i][j] = 1.0 / (Data)v.size();
    }
    Array b(N);
    REP(i,N) REP(j,N) b[i] -= A[i][j] * mat[i][j];
    REP(i,N) A[i][i] -= 1.0;
    SpMatrix SA;
    REP(i,N) {
      SpArray sa;
      REP(j,N) {
        if (abs(A[i][j]) > eps) sa[j] = A[i][j];
      }
      if (!sa.empty()) SA[i] = sa;
    }
    SpArray SB;
    REP(i,N) if (abs(b[i]) > eps) SB[i] = b[i];
    Array x = CG_method(SA, SB, N);
    cout << setprecision(12) << fixed << x[S] << endl;
  }
  return 0;
}

Measured memory_bytes: 2992