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

#FW0000026. Tránh gặp sếp (Avoiding Your Boss)

HỌC THEO LỘ TRÌNH

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

1 lộ trình

Tránh gặp sếp (Avoiding Your Boss)

Avoiding Your Boss

Source: UVa

Version: Phuoc Hung OJ Extended

Problem Statement

In an undirected weighted road graph, a boss travels from home bb to office oo via any shortest route. Avoid every vertex belonging to any boss-shortest route (including endpoints), then find the shortest cost from yy to mm.

Input

n,r,b,o,y,mn,r,b,o,y,m followed by rr weighted undirected roads.

Output

Print the shortest cost or exactly MISSION IMPOSSIBLE..

Subtasks

  • Subtask 1 (40 points): n≤8n\le 8; 2≤n≤1002\le n\le 100; 0≤r≤100000\le r\le 10000; 1≤b,o,y,m,u,v≤n1\le b,o,y,m,u,v\le n; 1≤w≤1001\le w\le 100.
  • Subtask 2 (60 points): 2≤n≤1002\le n\le 100; 0≤r≤100000\le r\le 10000; 1≤b,o,y,m,u,v≤n1\le b,o,y,m,u,v\le n; 1≤w≤1001\le w\le 100.

Examples

Input

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

Output

MISSION IMPOSSIBLE.

Explanation

Every vertex 1,2,31,2,3 belongs to the boss’s shortest path. The employee begins at a forbidden vertex 22, so the mission is impossible.