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

#FW0000072. Xây dựng đường mới (Road Construction)

HỌC THEO LỘ TRÌNH

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

1 lộ trình

Xây dựng đường mới (Road Construction)

Road Construction

Source: UVa

Version: Phuoc Hung OJ Extended

Problem Statement

Cities are points in the plane, with existing undirected roads weighted by Euclidean length. Add at most one missing road to maximize the decrease in the sum of shortest distances over unordered city pairs. Improvement must exceed 11. Ties favor the shorter proposed road, then lexicographically smaller endpoints.

Input

First n,mn,m; then nn integer coordinate pairs and mm existing undirected edges u,vu,v (1-based). The initial graph is connected without duplicate edges.

Output

Print u v (with u<vu<v) for the chosen road, or No road required.

Subtasks

  • Subtask 1 (40 points): 3≤n≤73\le n\le 7. n−1≤m≤n(n−1)/2n-1\le m\le n(n-1)/2, −1000≤xi,yi≤1000-1000\le x_i,y_i\le1000; tọa độ phân biệt, đồ thị liên thông.

  • Subtask 2 (60 points): 3≤n≤203\le n\le 20. n−1≤m≤n(n−1)/2n-1\le m\le n(n-1)/2, −1000≤xi,yi≤1000-1000\le x_i,y_i\le1000; tọa độ phân biệt, đồ thị liên thông.

Examples

Input

3 2
0 0
0 3
4 0
1 2
2 3

Output

1 3

Explanation

The original route 1–2–3 costs 8. Adding the straight 1–3 road costs 4 and improves the total by 4, which exceeds the required threshold.