#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


template<typename K>
struct Matrix{
  typedef vector<K> arr;
  typedef vector<arr> mat;
  mat dat;

  Matrix(size_t r,size_t c):dat(r,arr(c,K())){}
  Matrix(mat dat):dat(dat){}

  size_t size() const{return dat.size();};
  bool empty() const{return size()==0;};
  arr& operator[](size_t k){return dat[k];};
  const arr& operator[](size_t k) const {return dat[k];};
  
  static Matrix cross(const Matrix &A,const Matrix &B){
    Matrix res(A.size(),B[0].size());    
    for(int i=0;i<(int)A.size();i++)
      for(int j=0;j<(int)B[0].size();j++)
        for(int k=0;k<(int)B.size();k++)
          res[i][j]+=A[i][k]*B[k][j];
    return res;
  }

  static Matrix identity(size_t n){
    Matrix res(n,n);
    for(int i=0;i<(int)n;i++) res[i][i]=K(1);
    return res;
  }
  
  Matrix pow(long long n) const{
    Matrix a(dat),res=identity(size());
    while(n){
      if(n&1) res=cross(res,a);
      a=cross(a,a);      
      n>>=1;
    }
    return res;
  }

  template<typename T> using ET = enable_if<is_floating_point<T>::value>;
  template<typename T> using EF = enable_if<!is_floating_point<T>::value>;
  
  template<typename T, typename ET<T>::type* = nullptr>
  static bool is_zero(T x){return abs(x)<1e-8;}
  template<typename T, typename EF<T>::type* = nullptr>
  static bool is_zero(T x){return x==T(0);}

  static Matrix gauss_jordan(const Matrix &A,const Matrix &B){
    int n=A.size(),l=B[0].size();
    Matrix C(n,n+l);
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++)
        C[i][j]=A[i][j];      
      for(int j=0;j<l;j++)
        C[i][n+j]=B[i][j];
    }
    for(int i=0;i<n;i++){
      int p=i;
      for(int j=i;j<n;j++)
        if(abs(C[p][i])<abs(C[j][i])) p=j;
      swap(C[i],C[p]);
      if(is_zero(C[i][i])) return Matrix(0,0);
      for(int j=i+1;j<n+l;j++) C[i][j]/=C[i][i];
      for(int j=0;j<n;j++){
        if(i==j) continue;
        for(int k=i+1;k<n+l;k++)
          C[j][k]-=C[j][i]*C[i][k];
      }
    }
    Matrix res(n,l);
    for(int i=0;i<n;i++)
      for(int j=0;j<l;j++)
        res[i][j]=C[i][n+j];
    return res;
  }
  
  Matrix inv() const{
    Matrix B=identity(size());
    return gauss_jordan(*this,B);
  }
  
  K determinant() const{
    Matrix A(dat);
    K res(1);
    int n=size();
    for(int i=0;i<n;i++){
      int p=i;
      for(int j=i;j<n;j++)
        if(abs(A[p][i])<abs(A[j][i])) p=j;      
      if(i!=p) swap(A[i],A[p]),res=-res;      
      if(is_zero(A[i][i])) return K(0);      
      res*=A[i][i];
      for(int j=i+1;j<n;j++) A[i][j]/=A[i][i];
      for(int j=i+1;j<n;j++)
        for(int k=i+1;k<n;k++)
          A[j][k]-=A[j][i]*A[i][k];
    }
    return res;
  }

  static arr linear_equations(const Matrix &A,const arr &b){
    Matrix B(b.size(),1);
    for(int i=0;i<(int)b.size();i++) B[i][0]=b[i];
    Matrix tmp=gauss_jordan(A,B);
    arr res(tmp.size());
    for(int i=0;i<(int)tmp.size();i++) res[i]=tmp[i][0];
    return res;
  }
  
  static K sigma(K x,long long n){
    Matrix A(2,2);
    A[0][0]=x;A[0][1]=0;
    A[1][0]=1;A[1][1]=1;
    return A.pow(n)[1][0];
  }
};


struct Precision{
  Precision(){
    cout<<fixed<<setprecision(12);
  }
}precision_beet;


template <typename T>
vector<T> dijkstra(int s,vector<vector<pair<int, T> > > & G,T INF){
  using P = pair<T, int>;
  int n=G.size();
  vector<T> d(n,INF);
  vector<int> b(n,-1);
  priority_queue<P,vector<P>,greater<P> > q;
  d[s]=0;
  q.emplace(d[s],s);
  while(!q.empty()){
    P p=q.top();q.pop();
    int v=p.second;
    if(d[v]<p.first) continue;
    for(auto& e:G[v]){
      int u=e.first;
      T c=e.second;
      if(d[u]>d[v]+c){
        d[u]=d[v]+c;
        b[u]=v;
        q.emplace(d[u],u);
      }
    }
  }
  return d;
}

//INSERT ABOVE HERE
signed main(){
  int n,s,t;
  while(cin>>n>>s>>t,n){
    s--;t--;
    vector<int> q(n);
    for(int i=0;i<n;i++) cin>>q[i];
    vector<vector<int> >  a(n,vector<int>(n));
    for(int i=0;i<n;i++)
      for(int j=0;j<n;j++)
        cin>>a[i][j];

    const int INF = 1LL<<20;
    vector<int> dist;
    {
      using P = pair<int, int>;
      vector<vector<P> > G(n);
      for(int i=0;i<n;i++)
        for(int j=0;j<n;j++)
          if(a[i][j]) G[i].emplace_back(j,a[i][j]);
      dist=dijkstra(t,G,INF);
    }
    if(dist[s]==INF){
      cout<<"impossible"<<endl;
      continue;
    }

    vector<vector<int> > G(n);
    for(int i=0;i<n;i++){
      if(q[i]==1){
        for(int j=0;j<n;j++)
          if(a[j][i]&&(dist[j]+a[j][i]==dist[i])) G[i].emplace_back(j);      
      }
      if(q[i]==0){
        for(int j=0;j<n;j++)
          if(a[i][j]) G[i].emplace_back(j);     
      }
    }

    using MM = Matrix<double>;
    MM A(n+1,n+1);
    for(int i=0;i<=n;i++)
      for(int j=0;j<=n;j++)
        A[i][j]=0;
    A[n][n]=1;

    for(int v=0;v<n;v++){
      if(dist[v]==INF||v==t) continue;      
      for(int u:G[v]){
        A[v][u]=1.0/G[v].size();
        A[v][n]+=(double)a[v][u]/G[v].size();
      }
    }
    
    MM B(n+1,1);
    for(int i=0;i<=n;i++) B[i][0]=i==n;

    if(0){
      auto print=
        [&](MM X){
          int row=X.size();
          for(int i=0;i<row;i++){
            for(double v:X[i])
              cout<<v<<" ";
            cout<<endl;
          }
          cout<<endl;
        };
      print(A);
      for(int i=0;i<1000;i++){
        B=MM::cross(A,B);
      }
      print(B);
    }
    
    cout<<MM::cross(A.pow(1LL<<20),B)[s][0]<<endl;
  }
  return 0;
}



Measured memory_bytes: 3600