#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
typedef vector<double> Vector;
typedef vector<Vector> Matrix;


// [x, y]を[r, 0]に変換するc, sを計算する
inline void make_param(double x, double y, double& c, double &s){
  double r = sqrt(x * x + y * y);
  c = x / r, s = y / r;
}
// 回転行列[[c, s], [-s, c]]を[x, y]に適用する
inline void rotate(double& x, double& y, double c, double s){
  double u = c * x + s * y;
  double v = -s * x + c * y;
  x = u, y = v;
}

// Ax = bを解く
Vector givens_elimination(Matrix A, Vector b){
  int n = A.size();
  for(int i = 0; i < n; i++){
    for(int i2 = i + 1; i2 < n; i2++){
      double c, s;
      make_param(A[i][i], A[i2][i], c, s);
      rotate(b[i], b[i2], c, s);
      for(int j = i; j < n; j++){
        rotate(A[i][j], A[i2][j], c, s);
      }
    }
  }
  for(int i = n - 1; i >= 0; i--){
    b[i] /= A[i][i];
    for(int j = i - 1; j >= 0; j--){
      b[j] -= A[j][i] * b[i];
    }
  }
  return b;
}
int main(){
  int N, S, T;
  while(cin >> N >> S >> T && N){
    S--; T--;
    vector<int> have_sign(N, 0);
    REP(i, N) cin >> have_sign[i];
    int dist[100][100] = {};
    vector<int> to[100];
    vector<int> cost[100];
    REP(i, N) REP(j, N){
      cin >> dist[i][j];
      if(dist[i][j] > 0){
        to[i].push_back(j);
        cost[i].push_back(dist[i][j]);
      }
      if(dist[i][j] == 0 && i != j) dist[i][j] = INF;
    }
    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] >= INF){
      cout << "impossible" << endl;
      continue;
    }

    vector<int> c_vertex;
    vector<bool> connect(N, false);
    map<int, int> vertex_idx;
    REP(i, N) if(dist[i][T] < INF){
      vertex_idx[i] = c_vertex.size();
      c_vertex.push_back(i);
      connect[i] = true;
    }
    int M = c_vertex.size();
    Matrix A(M, Vector(M, 0.0));
    Vector b(M, 0);
    REP(i, M){
      int u = c_vertex[i];
      A[u][u] = 1;
      if(u == T) continue; 
      vector<pair<int, int> > vec;
      REP(i, to[u].size()){
        int v = to[u][i];
        if(!connect[v]) continue;
        int c = cost[u][i];
        if(!have_sign[u] || c + dist[v][T] == dist[u][T]){
          vec.push_back(make_pair(vertex_idx[v], c));
        }
      }
      REP(i, vec.size()) {
        int k = vec[i].first;
        int c = vec[i].second;
        A[u][k] = -1.0 / vec.size();
        b[u] += 1.0 * c / vec.size();
      }
    }
    Vector ans = givens_elimination(A, b);
    printf("%.12f\n", ans[vertex_idx[S]]);
  }
  return 0;
}

Measured memory_bytes: 1568