#include <bits/stdc++.h>
using namespace std;

const double eps = 1e-10;

template <typename T>
struct Matrix {
    vector<vector<T>> mat;
    Matrix(size_t n, size_t m, T val = 0) : mat(n, vector<T>(m, val)) {};
    void init(size_t n, size_t m, T val = 0) {mat.assigin(n, vector<T>(m, val));}
    size_t size() const {return mat.size();}
    inline vector<T>& operator[](size_t i) {return mat[i];}
};

size_t gauss_jordan(Matrix<double> &A, bool extended = false) {
    size_t m = A.size(), n = A[0].size();
    size_t rank = 0;

    for(size_t col = 0; col < n; ++col) {
        if(extended && col + 1 == n) break;

        // select a pivot
        int pivot = -1;
        double ma = eps;
        for(size_t row = rank; row < m; ++row) {
            if(fabs(A[row][col]) > ma) {
                pivot = row;
                ma = abs(A[row][col]);
            }
        }
        if(pivot == -1) continue;

        // divide
        swap(A[pivot], A[rank]);
        double factor = A[rank][col];
        for(size_t c = 0; c < n; ++c) A[rank][c] /= factor;

        // sweep
        for(size_t row = 0; row < m; ++row) {
            if(row != rank && abs(A[row][col]) > eps) {
                double factor = A[row][col];
                for(size_t c = 0; c < n; ++c) {
                    A[row][c] -= A[rank][c] * factor;
                }
            }
        }

        ++rank;
    }
    
    return rank;
}

size_t solve(Matrix<double> A, vector<double> b, vector<double> &res) {
    // prepare
    size_t m = A.size(), n = A[0].size();
    Matrix<double> coeff(m, n + 1);
    for(size_t row = 0; row < m; ++row) {
        for(size_t col = 0; col < n; ++col) coeff[row][col] = A[row][col];
        coeff[row][n] = b[row];
    }
    
    // Gauss-Jordan Elimination
    size_t rank = gauss_jordan(coeff, true);

    // No solution
    for(size_t row = rank; rank < m; ++rank) {
        if(fabs(coeff[row][n]) > eps) return -1;
    };

    // pack res with a solution
    res.resize(n, 0);
    size_t row = 0;
    for(size_t j = 0; j < n; ++j) {
        if(fabs(coeff[row][j]) > eps) {
            res[j] = coeff[row][n];
            ++row;
        }
    }

    return rank;
}

template <typename T>
vector<vector<int>> dijkstra(const vector<vector<int>> &G, int source) {
    const T INF = numeric_limits<T>::max();
    using P = pair<T, int>;

    vector<T> dist(G.size(), INF);
    dist[source] = 0;

    priority_queue<P, vector<P>, greater<P>> que;
    que.emplace(0, source);

    vector<vector<int>> pred(G.size(), vector<int>());

    while(!que.empty()) {
        P p = que.top();
        que.pop();
        int v = p.second;
        if(dist[v] < p.first) continue;

        for(size_t to = 0; to < G.size(); ++to) {
            if(G[v][to] == 0) continue;

            if(dist[to] > dist[v] + G[v][to]) {
                dist[to] = dist[v] + G[v][to];
                que.emplace(dist[to], to);
                pred[to].clear();
                pred[to].push_back(v);
            } else if(dist[to] == dist[v] + G[v][to]) {
                pred[to].push_back(v);
            }
        }
    }

    return pred;
}

int main() {
    while(true) {
        int n, s, t;
        cin >> n >> s >> t;
        if(n == 0) return 0;
        --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];
        }

        auto next = dijkstra<int>(A, t);
        if(next[s].size() == 0) {
            cout << "impossible" << endl;
            continue;
        }

        Matrix<double> M(n, n, 0.0);
        vector<double> B(n);
        for(int v = 0; v < n; ++v) {
            if(v == t) {
                M[v][t] = 1;
                continue;
            }
            if(q[v]) {
                for(int to : next[v]) {
                    M[v][to] -= 1;
                    B[v] += A[v][to];
                }
                M[v][v] += next[v].size();
            } else {
                int cnt = 0;
                for(int to = 0; to < n; ++to) {
                    if(A[v][to] == 0) continue;
                    M[v][to] -= 1;
                    B[v] += A[v][to];
                    ++cnt;
                }
                M[v][v] += cnt;
            }
        }

        vector<double> res(n);
        solve(M, B, res);
        cout << fixed << setprecision(9) << res[s] << endl;
    }
}


Measured memory_bytes: 3308