#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>


#define fs first
#define sc second

using namespace std;

typedef pair<int, int> P;
typedef long long ll;

const double EPS = 1E-8;
typedef vector<double> vec;
typedef vector<vec> mat;


// Ax = bを解く。 Aは正方行列。
vec gauss_jordan(const mat& A, const vec& b){
    int n = A.size();
    mat B(n, vec(n+1));
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            B[i][j] = A[i][j];
        }
    }

    for(int i = 0; i < n; i++){
        B[i][n] = b[i];
    }

    for(int i = 0; i < n; i++){
        int pivot = i;
        for(int j = i; j < n; j++){
            if(abs(B[j][i]) > abs(B[pivot][i])){
                pivot = j;
            }
        }
        swap(B[i], B[pivot]);

        if(abs(B[i][i]) < EPS){
            return vec();
        }

        for(int j = i + 1; j <= n; j++){
            B[i][j] /= B[i][i];
        }
        for(int j = 0; j < n; j++){
            if(i != j){
                for(int k = i + 1; k <= n; k++){
                    B[j][k] -= B[j][i] * B[i][k];
                }
            }
        }

    }

    vec x(n);
    for(int i = 0; i < n; i++){
        x[i] = B[i][n];
    }
    return x;

}

int dis[100];
int q[100];
bool used[100];
int cost[100][100];

int n;
// Pのfirstが最短距離、secondが頂点番号


void dijkstra(int s){
    fill(dis, dis+n, INT32_MAX);
    fill(used, used+n, false);
    dis[s] = 0;

    while(true){
        int v = -1;
        for(int u = 0; u < n; u++) {
            if (!used[u] && (v == -1 || dis[u] < dis[v])) {
                v = u;
            }
        }
        if(v == -1){
            break;
        }
        used[v] = true;

        for(int u = 0; u < n; u++){
            dis[u] = min(dis[u], dis[v] + cost[v][u]);
        }
    }
}



int main() {
    while(true) {
        int s, t;
        cin >> n >> s >> t;
        if(n == 0 && s == 0 && t == 0){
            break;
        }
        s--;
        t--;
        for (int i = 0; i < n; i++) {
            cin >> q[i];
        }
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                cin >> cost[i][j];
                if (cost[i][j] == 0) {
                    cost[i][j] = 200 * 100;
                }
            }
        }

        for (int i = 0; i < n; i++) {
            dijkstra(t);
        }

        vector<int> m_list[100];
        for (int i = 0; i < n; i++) {
            int min_dis = INT32_MAX;
            if (i == t) {
                continue;
            }
            if (q[i] == 1) {
                for (int j = 0; j < n; j++) {
                    if (dis[i] < min_dis) {
                        min_dis = dis[i];
                    }
                }
                for (int j = 0; j < n; j++) {
                    if (cost[i][j] <= 10 && cost[i][j] + dis[j] == min_dis) {
                        m_list[i].push_back(j);
                    }
                }
            } else {
                for (int j = 0; j < n; j++) {
                    if (cost[i][j] <= 10) {
                        m_list[i].push_back(j);
                    }
                }
            }
        }

        mat A(n, vec(n, 0));
        vec b(n, 0);
        for (int i = 0; i < n; i++) {
            double cos = 0.0;
            if (i == t) {
                A[i][i] = 1.0;
                continue;
            }
            for (auto j: m_list[i]) {
                A[i][j] = -1.0 / (double) m_list[i].size();
                cos += cost[i][j] * (-A[i][j]);
            }
            b[i] = cos;
            A[i][i] += 1.0;
        }

        vec x = gauss_jordan(A, b);
        if (x.size() == 0) {
            cout << "impossible" << endl;
        } else {
            printf("%.8f\n", x[s]);
        }

    }

    return 0;
}



Measured memory_bytes: 3412