#!/usr/bin/env python3
n, m, w, f = map(int, input().split())
water_depots = list(map(int, input().split()))
food_depots = list(map(int, input().split()))

graph = [[] for _ in range(n)]
for _ in range(m):
    a, b, t = map(int, input().split())
    graph[a].append((b, t))
    graph[b].append((a, t))
