Language: C++

//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

struct edge {int to, cost;};
vector<edge> g[105];
//
int d[105][105], e[105];
signed main(void)
{
    //????????°?????¶????????????????????°
    while(true) {
        int n, m, l, k, a, h;
        cin >> n >> m >> l >> k >> a >> h;
        if(!n && !m && !l && !k && !a && !h) break;
        REP(i, n) e[i] = 0;
        REP(i, l) {
            int ee;
            cin >> ee;
            e[ee] = 1;
        }
        REP(i, n) g[i].erase(ALL(g[i]));
        REP(i, k) {
            int x, y, t;
            cin >> x >> y >> t;
            g[x].PB({y, t});
            g[y].PB({x, t});
        }

        priority_queue<VI, VVI, greater<VI>> que;
        fill(d[0], d[100], INF);
        d[m][a] = 0;
        que.push({m, 0, a});

        while(que.size()) {
            VI v = que.top(); que.pop();
            //cout << v[0] << " " << v[1] << " " << v[2] << endl;
            if(d[v[0]][v[2]] < v[1]) continue;
            //??????????¨??????????
            if(e[v[2]]) {
                REP(i, g[v[2]].size()) {
                    //cout << "i:" << i << " " << g[v[2]][i].to << " " << g[v[2]][i].cost << endl;
                    FOR(j, v[0], m+1) {
                        edge e = g[v[2]][i];
                        if(j-e.cost >= 0 && d[j-e.cost][e.to] > d[v[0]][v[2]] + e.cost + j - v[0]) {
                            d[j-e.cost][e.to] = d[v[0]][v[2]] + e.cost + j - v[0];
                            que.push({j-e.cost, d[j-e.cost][e.to], e.to});
                            //cout << "a:" << j-e.cost << " " << d[j-e.cost][e.to] << " " << e.to << endl;
                        }
                    }
                }
            } else {
                for(edge i: g[v[2]]) {
                    //cout << i.to << ":" << i.cost << " " << d[v[0]-i.cost][i.to] << " " << d[v[0]][v[2]] + i.cost << endl;
                    if(v[0]>=i.cost && d[v[0]-i.cost][i.to] > d[v[0]][v[2]] + i.cost) {
                        d[v[0]-i.cost][i.to] = d[v[0]][v[2]] + i.cost;
                        que.push({v[0]-i.cost, d[v[0]-i.cost][i.to], i.to});
                        //cout << "b:" << v[0] - i.cost << " " << d[v[0]-i.cost][i.to] << " " << i.to << endl; 
                    }
                }
            }
        }

        /*REP(i, n) {
            REP(j, m+1) {
                cout << d[j][i] << " ";
            }
            cout << endl;
        }*/

        int ans = INF;
        REP(i,m+1) ans = min(ans, d[i][h]);

Compiler output:
a.cc: In function 'int main()':
a.cc:66:40: warning: narrowing conversion of '(j - ((ll)e.edge::cost))' from 'll' {aka 'long long int'} to 'int' [-Wnarrowing]
   66 |                             que.push({j-e.cost, d[j-e.cost][e.to], e.to});
      |                                       ~^~~~~~~
a.cc:66:40: warning: narrowing conversion of '(j - ((ll)e.edge::cost))' from 'll' {aka 'long long int'} to 'int' [-Wnarrowing]
a.cc:91:44: error: expected '}' at end of input
   91 |         REP(i,m+1) ans = min(ans, d[i][h]);
      |                                            ^
a.cc:31:17: note: to match this '{'
   31 |     while(true) {
      |                 ^
a.cc:91:44: error: expected '}' at end of input
   91 |         REP(i,m+1) ans = min(ans, d[i][h]);
      |                                            ^
a.cc:29:1: note: to match this '{'
   29 | {
      | ^