#include #include #include #include #include template using MinHeap = std::priority_queue, std::greater>; using namespace std; using lint = long long; constexpr lint INF = 1LL << 60; void solve() { int n, s, t, k; cin >> n >> s >> t >> k; --s, --t; vector xs(n); for (auto& x : xs) cin >> x; vector>> graph(n); { int m; cin >> m; while (m--) { int u, v; lint c; cin >> u >> v >> c; graph[--u].emplace_back(--v, c); } } auto dp = vector(n, vector(k + 1, INF)); auto rev = vector(n, vector(k + 1, make_pair(-1, -1))); dp[s][1] = xs[s]; rev[s][1] = {0, 0}; MinHeap> heap; heap.emplace(dp[s][1], s, 1); while (!heap.empty()) { auto [d, v, p] = heap.top(); heap.pop(); if (dp[v][p] < d) continue; auto np = min(p + 1, k); for (auto [u, c] : graph[v]) { auto nd = d + c + xs[u]; if (dp[u][np] <= nd) continue; dp[u][np] = nd; rev[u][np] = {v, p}; heap.emplace(dp[u][np], u, np); } } if (dp[t][k] == INF) { cout << "Impossible\n"; return; } cout << "Possible\n" << dp[t][k] << "\n"; vector ans; { int v = t, p = k; while (p > 0) { ans.push_back(v); tie(v, p) = rev[v][p]; } reverse(ans.begin(), ans.end()); } cout << ans.size() << "\n"; for (auto v : ans) cout << v + 1 << " "; cout << "\n"; } int main() { cin.tie(nullptr); ios::sync_with_stdio(false); solve(); return 0; }