#include using namespace std; using ll = long long int; using iPair = pair; using lPair = pair; using ivector = vector; using lvector = vector; using istack = stack; using iqueue = queue; using ivv = vector>; using lvv = vector>; const int INF = 0x3f3f3f3f; const ll LINF = 0x3f3f3f3f3f3f3f3f; vector dir = {{1,0}, {-1,0}, {0,1}, {0,-1}}; #define dump(x) cout << #x << " = " << (x) << endl #define ALL(x) begin(x),end(x) #define rep(i,s,e) for(ll i=(s), i_stop=(e); i=i_stop; --i) #define range(i,s,n) for(ll i=(s), i_stop=(s)+(n); ii_stop; --i) #define foreach(x,container) for(auto &&x:container) template bool chmax(T& a, const T b) {if(a bool chmin(T& a, const T b) {if(a>b) {a=b;return true;} return false;} template void printArr(vector &arr){ for(auto &x:arr) {cout << x << " ";} cout << endl; } // =====================================================> /* */ ll n,m,s,t,k; lvector x; vector> g; void solve() { // 爲了方便計算,頂點從0開始 // 輸出的時候再加1 cin>>n>>s>>t>>k; --s; --t; x = lvector(n+1); range(i, 0, n) cin>>x[i]; cin>>m; g = vector>(n+1); while(m--) { ll a,b,y; cin>>a>>b>>y; --a; --b; g[a].emplace_back(b, y); } // 包含端點要有 K 個節點 // 0, 1, 2, ..., K-1 層 // 除開 K-1 層外,其他層都向上建邊 // 頂點編號 [0, n), [n, 2n), ..., [(k-1)n, kn) lvector dist(n*k, LINF); lvector prev(n*k, -1); using T = tuple; priority_queue, greater> pq; dist[s] = x[s]; pq.emplace(dist[s], s, -1); while(pq.size()) { auto [d, node, p] = pq.top(); pq.pop(); if(d > dist[node]) continue; prev[node] = p; if(node == (k-1)*n+t) break; // 鬆弛鄰點 ll layer = node / n; ll u = node % n; for(auto [v,w]: g[u]) { ll next_node = v + (layer + (layer!=k-1)) * n; if(chmin(dist[next_node], d+w+x[v])) { pq.emplace(d+w+x[v], next_node, node); } } } if(dist[(k-1)*n+t] == LINF) cout << "Impossible" << endl; else { cout << "Possible" << endl; cout << dist[(k-1)*n+t] << endl; lvector path; ll node = (k-1)*n+t; while(node != -1) { path.push_back(node); node = prev[node]; } cout << path.size() << endl; for(auto it=path.rbegin(); it!=path.rend(); ++it) { cout << (*it)%n+1 << " "; } cout << endl; } } int main(){ ios::sync_with_stdio(false); cin.tie(0); solve(); return 0; }