#include using namespace std; #define all(x) begin(x), end(x) #define sz(x) (ll)(x).size() using ll = long long; using ld = long double; constexpr ll INF = 0x3FFF'FFFF'FFFF'FFFF; mt19937_64 rng(123456789); struct why {//no one would ever do this... ll key, dist, id; why(ll dist_, ll id_) : key(rng()), dist(dist_), id(id_) {} bool operator<(const why& o) const { return key < o.key; } }; vector dijkstra(const vector>>& adj, ll s) { vector dist(sz(adj), INF); dist[s] = 0; priority_queue todo; todo.push(why(0, s)); while (!todo.empty()) { auto [_, d, c] = todo.top(); todo.pop(); if (d != dist[c]) continue; for (auto [w, x] : adj[c]) { if (w + d < dist[x]) { dist[x] = w + d; todo.push(why(dist[x], x)); } } } return dist; } int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); ll n, m, k; cin >> n >> m >> k; vector>> adj(n); for (ll i = 0; i < m; i++) { ll a, b, w; cin >> a >> b >> w; a--; b--; adj[a].push_back({w, b}); adj[b].push_back({w, a}); } vector> special(k); for (auto& [id, p] : special) cin >> id >> p, id--; auto dadj = dijkstra(adj, 0); auto drev = dijkstra(adj, n - 1); sort(all(special), [&](pair a, pair b){ return dadj[a.first] + drev[a.first] < dadj[b.first] + drev[b.first]; }); ld res = 0; ld logPrev = log2l(1.0); bool ok = false; for (auto [id, p] : special) { res += exp2l(log2l(dadj[id] + drev[id]) + logPrev + log2(p)); if (p >= 1.0) { ok = dadj[id] + drev[id] < INF; break; } logPrev += log2l(1 - p); } if (!ok) cout << "impossible" << endl; else cout << fixed << setprecision(20) << res << endl; }