/*
    このコードで進展がなければシコって風呂に入って寝ようと思っています。
 */

#include <cstdio>
#include <cstring>
#include <cassert>
#include <queue>
#include <algorithm>
using namespace std;

#define INF 0x7fffffff

typedef pair<int, int> Pair;
typedef pair<Pair, Pair> Pair2;
struct Data {
    int parent;
    int lowest;
};

int n;
int m;
int k;
int q;
bool used[100000];
int shortest[100000];
int depth[100000];
struct Data doubling[17][100000];
vector<Pair> es[200000];
vector<Pair> new_es[200000];

void dijkstra(priority_queue<Pair, vector<Pair>, greater<Pair> > &que) {
    while (!que.empty()) {
        Pair p = que.top(); que.pop();
        int cost = p.first;
        int from = p.second;

        if (shortest[from] < cost) continue;
        for (int i=0; i<es[from].size(); i++) {
            int to = es[from][i].first;
            int len = es[from][i].second;

            if (shortest[to] > len + cost) {
                shortest[to] = len + cost;
                que.push(Pair(shortest[to], to));
            }
        }
    }
}

void prim() {
    priority_queue<Pair2> que;
    vector<Pair> es_idx;

    for (int i=0; i<es[0].size(); i++) {
        int to = es[0][i].first;
        que.push(Pair2(Pair(es[0][i].second, to), Pair(0, i)));
    }

    fill(used, used+n, false);
    used[0] = true;
    while (!que.empty()) {
        Pair2 p = que.top(); que.pop();
        int from = p.first.second;

        if (used[from]) continue;
        used[from] = true;
        es_idx.push_back(p.second);

        for (int i=0; i<es[from].size(); i++) {
            int to = es[from][i].first;
            int len = es[from][i].second;

            if (!used[to]) que.push(Pair2(Pair(len, to), Pair(from, i)));
        }
    }

    for (int i=0; i<es_idx.size(); i++) {
        int from = es_idx[i].first;
        int idx = es_idx[i].second;
        new_es[from].push_back(es[from][idx]);
    }
}

void dfs(int node, int p, int d, int cost) {
    depth[node] = d;
    doubling[0][node].parent = p;
    doubling[0][node].lowest = cost;
    
    for (int i=0; i<new_es[node].size(); i++) {
        int to = new_es[node][i].first;
        if (to != p) dfs(to, node, d+1, new_es[node][i].second);
    }
}

void init() {
    for (int i=0; i<17; i++) {
        for (int j=0; j<n; j++) {
            doubling[i][j].parent = -1;
            doubling[i][j].lowest = INF;
        }
    }

    dfs(0, -1, 0, INF);

    for (int i=0; i<16; i++) {
        for (int j=0; j<n; j++) {
            struct Data *l = &doubling[i][j];
            struct Data *r;

            if (l->parent == -1) continue;
            r = &doubling[i][l->parent];
            doubling[i+1][j].parent = r->parent;
            doubling[i+1][j].lowest = min(l->lowest, r->lowest);
        }
    }
}

int lca(int u, int v) {
    int ans = min(shortest[u], shortest[v]);

    if (depth[u] > depth[v]) swap(u, v);
    for (int i=0; i<17; i++) {
        if ((depth[v] - depth[u]) >> i & 1) {
            ans = min(ans, doubling[i][v].lowest);
            v = doubling[i][v].parent;
        }
    }
    if (u == v) return ans;

    for (int i=16; i>=0; i--) {
        if (doubling[i][u].parent != doubling[i][v].parent) {
            ans = min(ans, doubling[i][u].lowest);
            ans = min(ans, doubling[i][v].lowest);
            u = doubling[i][u].parent;
            v = doubling[i][v].parent;
        }
    }
    return min(ans, doubling[0][u].lowest);
}

int main() {
    priority_queue<Pair, vector<Pair>, greater<Pair> > que;

    scanf("%d %d %d %d", &n, &m, &k, &q);

    for (int i=0; i<m; i++) {
        int a, b, l;
        scanf("%d %d %d", &a, &b, &l);
        a--;
        b--;
        es[a].push_back(Pair(b, l));
        es[b].push_back(Pair(a, l));
    }

    fill(shortest, shortest+n, INF);
    for (int i=0; i<k; i++) {
        int f;
        scanf("%d", &f);
        f--;
        shortest[f] = 0;
        que.push(Pair(0, f));
    }
    dijkstra(que);

    for (int i=0; i<n; i++) {
        for (int j=0; j<es[i].size(); j++) {
            int to = es[i][j].first;
            es[i][j].second = min(shortest[i], shortest[to]);
        }
    }

    prim();
    init();

    for (int i=0; i<q; i++) {
        int a, b;
        int ans;

        scanf("%d %d", &a, &b);
        a--;
        b--;
        ans = lca(a, b); 
        printf("%d\n", ans);
    }
}

Measured memory_bytes: 33568