#include #include using namespace std; using ll=long long; typedef pair P; const long long INF = 1e18; int main() { ll N, S, T, K; cin >> N >> S >> T >> K; vector X(N + 1); for (int i = 1; i <= N; i++) cin >> X[i]; ll M; cin >> M; vector>E(N + 1); ll A, B, Y; for (int i = 0; i < M; i++) { cin >> A >> B >> Y; E[A].push_back({ B, Y }); } vector> DP(N + 1, vector(K + 1, INF)); DP[S][1] = X[S]; vector>Prev(N + 1, vector

(K + 1, { 0, 0 })); priority_queue, vector>, greater>>Q; Q.push(make_pair(0LL,make_pair(S,1))); pair R; ll d,x,k,y,m; while (!Q.empty()) { R = Q.top(); Q.pop(); d=R.first; x=R.second.first; k=R.second.second; if (DP[x][k] < d) continue; if (x == T && k == K) break; long long L = min(K, k + 1); for (P a : E[x]) { y = a.first, m = a.second; if (DP[x][k] + m + X[y] < DP[y][L]) { DP[y][L] = DP[x][k] + m + X[y]; Prev[y][L] = { x, k }; Q.push({DP[y][L],{y,L} }); } } } if (DP[T][K] >= INF) { cout << "Impossible" << endl; return 0; } x = T; k = K; vectorZ; while (k > 0) { Z.push_back(x); P ans = Prev[x][k]; x = ans.first; k = ans.second; } cout << "Possible" << endl << DP[T][K] << endl << Z.size() << endl; for (long long i = Z.size() - 1; i >= 0; i--) { if (i != Z.size() - 1) cout << ' '; cout << Z[i]; } cout << endl; }