Monocarp is preparing a team programming contest. The contest has $$$n$$$ problems, each of which is either easy or hard. The problems are numbered from $$$1$$$ to $$$n$$$.
Monocarp wants the first and the last problems of the contest to be easy. In one operation, he can choose any two problems and swap them.
Determine the minimum number of operations required to make the first and the last problems easy, or report that it is impossible.
The first line contains an integer $$$t$$$ ($$$1 \le t \le 10^3$$$) — the number of test cases.
Each test case consists of two lines
For each test case, print the minimum number of operations required to make the first and the last problems easy. If it is impossible to satisfy the requirement, print $$$-1$$$.
420 020 161 0 0 1 0 051 0 0 1 1
0-112
In the first test case, the first and the last problems are already easy, so no operations are needed.
In the second test case, there is only one easy problem, so it is impossible to make both the first and the last problems easy.
In the third test case, one can swap the first and the second problems.
In the fourth test case, one can first swap the first and the second problems, and then — the third and the fifth problems.