Output #1
2
* If the first bridge is closed: By taking the sequence of islands $(a_0, a_1, a_2) = (1, 3, 2)$, it is possible to visit islands $1, 3, 2$ in order, and a tour of length $2$ can be conducted. There is no shorter tour.
* If the second bridge is closed: By taking the sequence of islands $(a_0, a_1, a_2, a_3) = (1, 3, 1, 2)$, it is possible to visit islands $1, 3, 2$ in order, and a tour of length $3$ can be conducted. There is no shorter tour.
* If the third bridge is closed: By taking the sequence of islands $(a_0, a_1, a_2, a_3) = (1, 2, 3, 2)$, it is possible to visit islands $1, 3, 2$ in order, and a tour of length $3$ can be conducted. There is no shorter tour.
Therefore, the minimum possible length of the tour when the bridge to be closed is chosen optimally is $2$.
The following figure shows, from left to right, the cases when bridges $1, 2, 3$ are closed, respectively. The circles with numbers represent islands, the lines connecting the circles represent bridges, and the blue arrows represent the shortest tour routes.
