PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#FW0000075. Vị trí trạm cứu hỏa mới (Fire Station)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Vị trí trạm cứu hỏa mới (Fire Station)

Fire Station

Source: UVa

Version: Phuoc Hung OJ Extended

Problem Statement

Given a connected undirected road network and existing fire stations, choose one new station location that minimizes the maximum distance from any intersection to its closest station. Break ties by the smallest intersection index. Reusing an existing station location is allowed.

Input

First n,m,fn,m,f, followed by ff existing station vertices and then mm undirected weighted roads, all 1-based.

Output

Print the selected intersection index.

Subtasks

  • Subtask 1 (40 points): 2≤n≤7, 1≤f≤n2\le n\le 7,\ 1\le f\le n. n−1≤m≤n(n−1)/2n-1\le m\le n(n-1)/2, 1≤w≤1061\le w\le10^6, 1≤f≤n1\le f\le n; đồ thị liên thông.

  • Subtask 2 (60 points): 2≤n≤18, 1≤f≤n2\le n\le 18,\ 1\le f\le n. n−1≤m≤n(n−1)/2n-1\le m\le n(n-1)/2, 1≤w≤1061\le w\le10^6, 1≤f≤n1\le f\le n; đồ thị liên thông.

Examples

Input

4 3 1
1
1 2 2
2 3 3
3 4 5

Output

3

Explanation

The existing station is at vertex 1. Candidates 3 and 4 both achieve maximum response distance 5, so the lower-numbered intersection 3 is chosen.