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

#FW0000015. Đội đặc nhiệm (Commandos)

HỌC THEO LỘ TRÌNH

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

1 lộ trình

Đội đặc nhiệm (Commandos)

Commandos

Source: UVa

Version: Phuoc Hung OJ Extended

Problem Statement

Buildings are connected by undirected unit-time corridors. A team begins at ss, must cover all buildings and reassemble at tt, with arbitrarily many agents allowed in parallel. Find the minimum total mission time.

Input

n,mn,m, then mm undirected edges with zero-based endpoints; finally s,ts,t.

Output

Print the minimum mission time.

Subtasks

  • Subtask 1 (40 points): n≤8n\le 8; 2≤n≤1002\le n\le 100; 1≤m≤49501\le m\le 4950; 0≤u,v,s,t<n0\le u,v,s,t<n; đồ thị liên thông.
  • Subtask 2 (60 points): 2≤n≤1002\le n\le 100; 1≤m≤49501\le m\le 4950; 0≤u,v,s,t<n0\le u,v,s,t<n; đồ thị liên thông.

Examples

Input

4 3
0 1
1 2
2 3
0 3

Output

3

Explanation

For each building vv on the chain, d[0][v]+d[v][3]=3d[0][v]+d[v][3]=3, so the mission completes in 33 time units.