#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 100

typedef vector<double> V;
typedef vector<V> MATRIX;
int N,start,goal;
int dist[NUM][NUM],min_dist[NUM][NUM];
bool exist_sign[NUM];

void gauss_jordan(MATRIX A){

	MATRIX C(N,V(N+1));

	for(int row = 0; row < N; row++){
		for(int col = 0; col <= N; col++){
			C[row][col] = A[row][col];
		}
	}

	int base_row;
	double tmp;

	for(int i = 0; i < N; i++){
		base_row = i;
		for(int row = i+1; row < N; row++){
			if(fabs(C[row][i]) > fabs(C[base_row][i])){
				base_row = row;
			}
		}

		if(fabs(C[base_row][i]) < EPS)continue;

		if(base_row != i)swap(C[base_row],C[i]);

		tmp = C[i][i];
		for(int col = 0; col <= N; col++){
			C[i][col] /= tmp;
		}

		for(int row = 0; row < N; row++){
			if(row == i || fabs(C[row][i]) < EPS)continue;

			tmp = C[row][i];

			for(int col = i; col <= N; col++){
				C[row][col] -= C[i][col]*tmp;
			}
		}
	}

	printf("%.10lf\n",C[start][N]);
}

void func(){

	start--;
	goal--;

	for(int i = 0; i < N; i++){
		for(int k = 0; k < N; k++){
			if(i != k){
				dist[i][k] = BIG_NUM;
				min_dist[i][k] = BIG_NUM;
			}else{
				dist[i][k] = 0;
				min_dist[i][k] = 0;
			}
		}
	}

	int tmp;
	for(int i = 0; i < N; i++){

		scanf("%d",&tmp);
		exist_sign[i] = (tmp == 1);
	}

	for(int i = 0; i < N; i++){
		for(int k = 0; k < N; k++){
			scanf("%d",&tmp);
			if(tmp == 0)continue;
			dist[i][k] = tmp;
			min_dist[i][k] = tmp;
		}
	}

	for(int mid = 0; mid < N; mid++){
		for(int st = 0; st < N; st++){
			if(min_dist[st][mid] == BIG_NUM)continue;
			for(int gl = 0; gl < N; gl++){
				if(min_dist[mid][gl] == BIG_NUM)continue;
				min_dist[st][gl] = min(min_dist[st][gl],min_dist[st][mid]+min_dist[mid][gl]);
			}
		}
	}

	if(min_dist[start][goal] == BIG_NUM){
		printf("impossible\n");
		return;
	}

	MATRIX A(N,V(N+1));

	for(int row = 0; row < N; row++){
		for(int col = 0; col <= N; col++){
			A[row][col] = 0;
		}
	}

	int count;

	for(int i = 0; i < N; i++){

		if(min_dist[i][goal] == BIG_NUM || i == goal){
			A[i][i] = 1;
			continue;
		}

		if(exist_sign[i]){

			count = 0,tmp = 0;

			for(int k = 0; k < N; k++){
				if(k == i)continue;
				if(dist[i][k] == BIG_NUM || min_dist[k][goal] == BIG_NUM)continue;

				if(dist[i][k]+min_dist[k][goal] == min_dist[i][goal]){
					count++;
					tmp += dist[i][k];
					A[i][k] = -1;
				}
			}

			A[i][i] = count;
			A[i][N] = tmp;

		}else{

			count = 0,tmp = 0;

			for(int k = 0; k < N; k++){
				if(k == i)continue;
				if(dist[i][k] == BIG_NUM)continue;

				count++;
				tmp += dist[i][k];
				A[i][k] = -1;
			}
			A[i][i] = count;
			A[i][N] = tmp;
		}
	}


	gauss_jordan(A);
}

int main(){

	while(true){
		scanf("%d %d %d",&N,&start,&goal);
		if(N == 0 && start == 0 && goal == 0)break;

		func();
	}

	return 0;
}

