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

#FW0000014. Địa điểm hội họp (05-32 Rendezvous)

HỌC THEO LỘ TRÌNH

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

1 lộ trình

Địa điểm hội họp (05-32 Rendezvous)

05-32 Rendezvous

Source: UVa

Version: Phuoc Hung OJ Extended

Problem Statement

Each of nn participants lives at a location. Choose whose home minimizes the sum of shortest undirected travel costs from everyone; on ties choose the earliest input name.

Input

n,mn,m, followed by nn names and mm weighted undirected edges.

Output

Print the selected participant name.

Subtasks

  • Subtask 1 (40 points): n≤8n\le 8; 2≤n≤202\le n\le 20; 1≤m≤1901\le m\le 190; 1≤u,v≤n1\le u,v\le n; 1≤w≤1000001\le w\le 100000.
  • Subtask 2 (60 points): 2≤n≤202\le n\le 20; 1≤m≤1901\le m\le 190; 1≤u,v≤n1\le u,v\le n; 1≤w≤1000001\le w\le 100000.

Examples

Input

3 2
Ana
Ben
Cam
1 2 1
2 3 1

Output

Ben

Explanation

Meeting at Ben gives total cost 1+1=21+1=2, compared with 33 at either endpoint.