#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>
#include <random>

#define FOR_LT(i, beg, end) for (int i = (int)(beg); i < (int)(end); i++)
#define FOR_LE(i, beg, end) for (int i = (int)(beg); i <= (int)(end); i++)
#define FOR_DW(i, beg, end) for (int i = (int)(beg); (int)(end) <= i; i--)
#define REP(n)              for (int repeat_index = 0; repeat_index < (int)n; repeat_index++)


using namespace std;

static const double kEPS = 1e-10;

template <typename T>
struct Matrix {
	Matrix(size_t m, size_t n, T x = 0) : val_(vector<vector<T>>(m, vector<T>(n, x))) {}

	void Init(size_t m, size_t n, T x = 0)
	{
		this->val_.assign(vector<vector<T>>(m, vector<T>(n, x)));
	}

	size_t size() {
		return this->val_.size();
	}

	inline vector<T>& operator [] (int i) { return this->val_[i]; }

    void print() {
        for (auto& v : val_) {
            for (auto& t : v) {
                cout << t << " ";
            }
            cout << endl;
        }
    }

	vector<vector<T>> val_;
};

template<class T>
int gauss_jordan(Matrix<T>& A, bool is_extended = false) {
    int m = A.size(), n = A[0].size();

    int rank = 0;
    for (int col = 0; col < n; ++col) {
        if (is_extended && col == n - 1) break;

        int pivot = -1;
        T ma = kEPS;
        for (int row = rank; row < m; ++row) {
            if (abs(A[row][col]) > ma) {
                ma = abs(A[row][col]);
                pivot = row;
            }
        }
        if (pivot == -1) continue;

        swap(A[pivot], A[rank]);
        {
            auto fac = A[rank][col];

            for (int col2 = 0; col2 < n; ++col2) {
                A[rank][col2] /= fac;
            }
        }

        for (int row = 0; row < m; ++row) {
            if (row != rank && abs(A[row][col]) > kEPS) {
                auto fac = A[row][col];
                for (int col2 = 0; col2 < n; ++col2) {
                    A[row][col2] -= A[rank][col2] * fac;
                }
            }
        }

        ++rank;
    }

    return rank;
}


template<class T> vector<T> linear_equation(Matrix<T> A, vector<T> b)
{
    int m = A.size(), n = A[0].size();

    Matrix<T> M(m, n + 1);
    for (int i = 0; i < m; ++i) {
        for (int j = 0; j < n; ++j) M[i][j] = A[i][j];
        M[i][n] = b[i];
    }
    int rank = gauss_jordan(M, true);

    vector<T> res;
    for (int row = rank; row < m; ++row) {
        if (abs(M[row][n]) > kEPS) return res;
    }
    
    res.assign(n, 0);
    for (int i = 0; i < rank; ++i) res[i] = M[i][n];
    return res;
}

int solve()
{
    int n, s, t; cin >> n >> s >> t;
    if (n + s + t == 0) return 0;
    
    s--; t--;
    vector<int> has_s(n);
    FOR_LT(i, 0, n) {
        cin >> has_s[i];
    }

    Matrix<double> A(n, n);
    FOR_LT(i, 0, n) {
        FOR_LT(j, 0, n) {
            cin >> A[i][j];
        }
    }

    vector<int64_t> dist(n, -1);
    {
        struct D {
            int i;
            int64_t d;
        };
        auto cmp = [](D& lhs, D& rhs) {
            return lhs.d > rhs.d;
        };

        priority_queue <D, vector<D>, decltype(cmp)> search(cmp);
        vector<bool> is_ps(n);
        dist[t] = 0;
        is_ps[t] = false;

        search.push({ t, 0 });
        while (!search.empty()) {
            auto d = search.top();
            search.pop();

            if (is_ps[d.i]) continue;
            is_ps[d.i] = true;

            FOR_LT(i, 0, n) {
                if (i == d.i) continue;
                if (A[d.i][i] == 0) continue;

                int64_t nd = d.d + (int64_t)A[d.i][i];
                if (dist[i] == -1 || nd < dist[i]) {
                    dist[i] = nd;
                    search.push({ i, nd });
                }
            }
        }
    }
    if (dist[s] == -1) {
        cout << "impossible" << endl;
        return -1;
    }

    Matrix<double> B(n, n);
    vector<double> b(n);
    FOR_LT(i, 0, n) {
        if (i == t) {
            B[i][i] = 1;
            b[i] = 0;
            continue;
        }

        double sum = 0;
        int m = 0;
        FOR_LT(j, 0, n) {
            if (A[i][j] == 0) continue;

            if (has_s[i]) {
                if (dist[j] + A[i][j] == dist[i]) {
                    B[i][j] = -1;
                    sum += A[i][j];
                    m++;
                }
            }
            else {
                B[i][j] = -1;
                sum += A[i][j];
                if (i != j) m++;
            }
        }
        B[i][i] = m;
        b[i] = sum;
    }

    auto ans = linear_equation(B, b);
    if (ans.empty()) {
        cout << "impossible" << endl;
        return -1;
    }
    cout << ans[s] << endl;

    return 1;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(20);

    while (true) {
        int f = solve();
        if (f == 0) return 0;
    }

	return 0;
}
