#P6890. Express Mail Taking

    ID: 5747 远端评测题 1500ms 512MiB 尝试: 0 已通过: 0 难度: (无) 上传者: 标签>2020中国大学生程序设计竞赛(CCPC) - 网络选拔赛

Express Mail Taking

Problem Description

Besides on the traditional classes,Baby Volcano also needs to learn how to take the express mails.

Usually express mails are stored in cabinets. In Baby Volcano's school,there are $n$ cabinets in a row,numbered by $1$ to $n$. The distance between two adjacent cabinets is $1$, and the entrance is at the cabinet $1$. Among all $n$ cabinets,the one numbered $k$ is special and it is used to enter the code and open the cabinet door.

Baby Volcano has $m$ express mails to take,the $i$-th is in the cabinet $a_i$.
Two express mails will not be stored in the same cabinet. Also there is no express mail in the cabinet $k$.

To prevent expresses from being stolen, Baby Volcano have to take these express mails one by one, starting at the entrance. Generally, if he wants to take the express mail $i$, he have to walk to cabinet $k$ first to enter the code, and then walks to cabinet $a_i$. After taking the last one,he walks to the entrance.

There are so many express mails to take, so Baby Volcano wants to find a taking order which minimize the distance he walks.

Input

The first line contains one integer $T(1 \le T \le 100)$,the number of testcases.

For each test cases,the first line contains three integer $n,m,k(1 \le k \le n \le 10^9,1 \le m < \min(n,10^6))$

The next line contains $m$ integer,the $i$-th stand for $a_i(1 \le a_i \le n,a_i \neq k)$.

The input guarantees that $\sum m \le 2 \times 10^6$

**Note:Because of the large input,it is prefered to use scanf instead of cin.**

Output

For each test case,Output a single line contains one integer,representing for the minimal walking distance.

2 10 2 5 6 7 10 2 5 3 4
14 10