#include #include #include #include #include using namespace std; const double DOUBLE_MAX = 1000000000.0; int main() { int n, m, p, a, b; while (cin >> n >> m >> p >> a >> b){ if (n == 0 && m == 0 && p == 0 && a == 0 && b == 0){ break; } int ticket[10]; for (int i = 0; i < n; ++i){ cin >> ticket[i]; } vector > > graph(m + 1); for (int i = 0; i < p; ++i){ int from, to; double cost; cin >> from >> to >> cost; graph[from].push_back(make_pair(to, cost)); graph[to].push_back(make_pair(from, cost)); } vector init_vec((1 << n), DOUBLE_MAX); vector > cache(m + 1, init_vec); multimap > map_open; map_open.insert(make_pair(0.0, make_pair(a, 0))); cache[a][0] = 0.0; while (!map_open.empty()){ double t = map_open.begin()->first; pair now = map_open.begin()->second; map_open.erase(map_open.begin()); if (cache[now.first][now.second] != t){ continue; } vector >& branch = graph[now.first]; /* for (vector >::iterator it = branch.begin(); it != branch.end(); ++it){ if (cache[it->first][now.second] > t + it->second){ cache[it->first][now.second] = t + it->second; map_open.insert(make_pair(t + it->second, make_pair(it->first, now.second))); } */ for (int i = 0; i < n; ++i){ int now_ticket = now.second; if (now_ticket & (1 << i)){ continue; } int next_ticket = now.second | (1 << i); for (vector >::iterator it = branch.begin(); it != branch.end(); ++it){ double temp_cost = t + (it->second / (double)ticket[i]); //cout << now.first << " " << next_ticket << " " << t << endl;; if (cache[it->first][next_ticket] > temp_cost){ cache[it->first][next_ticket] = temp_cost; //cout << it->first << " " << next_ticket << " " << temp_cost << endl; map_open.insert(make_pair(temp_cost, make_pair(it->first, next_ticket))); } } } } double answer = DOUBLE_MAX; /* for(int t = 0; t < (1 << n); ++t){ for (int city = 1; city <= m; ++city){ printf("%.02lf ", cache[city][t]); } printf("\n"); } */ for (int i = 0; i < (1 << n); ++i){ //cout << answer << " "; if (answer > cache[b][i]){ answer = cache[b][i]; } } //cout << endl; if (answer >= DOUBLE_MAX){ cout << "Impossible" << endl; } else { printf("%.05lf\n", answer); } //cout << endl; } return 0; }