Modular Taxi
시간 제한2초메모리 제한2048 MB
일직선 위 도시들의 인구가 주어질 때, s번 도시에서 f번 도시로 가는 최소 횟수의 모듈로 택시 이동 경로를 구해 출력하거나 Impossible을 출력한다.
문제
Longlandia is a very long country. All of its cities are located along a line segment. If we enumerate them from the beginning to the end of the segment, the -th city has inhabitants.
You need to get from city to city . For this purpose, an infinite number of taxis called Kaban-2, Kaban-3, Kaban-4, Kaban-5, ... operate in Longlandia. A taxi named Kaban- can take you from city to city if the numbers of inhabitants in all cities from to inclusive are congruent modulo . Formally, for any integer such that , the relation must hold.
Find the smallest number of taxi calls required to get from city to city , and output lines describing the route. If it is impossible to reach the destination by taxi, output "Impossible".
입력
The first line contains an integer : the number of cities in Longlandia ().
The second line contains integers : the population of each city ().
The third line contains two integers and : the starting and finishing city numbers (; ).
출력
Let be the smallest number of taxi calls required to get from city to city . Output lines of the form "Kaban-$m_i$ $s_i$ $f_i$", indicating that the -th trip will be made by taxi Kaban- and will take you from city to city (; ). The following equalities must hold: ; ; . And, of course, taxi Kaban- must be able to take you from city to city .
If it is impossible to reach from to with any number of taxi calls, output the word "Impossible".
Letter case does not matter, so you can output, for example, "kaBAN" and "IMPossiBle".