Welcome to ZOJ
Select Problem
ZOJ Problem Set - 2276
Lara Croft

Time Limit: 2 Seconds      Memory Limit: 65536 KB

Lara Croft Tomb Raider is my favourite game. Lara Croft is a brave girl who loves exploration. One time she was be trapped in a place where the only exit was locked.

The lock was special: it was surrounded by a circle of n number, A1,A2,...,An. Initally, there were two sliding square on the number, each time, you can only move either of the two squares around the circle in Ai grid clockwise or anticlockwise. The two square can cross each other. The door is opened when the two squares are in the same position.

Can you help lara escape the dangerous place in the least time, or our poor Lara can't open the door.


The input file contains several test cases.

Each case begins with a natural number n(0<n<=100), then follow n number A1,A2,...,An in clockwise. Then the two squares' position P1,P2 ( 0<=P1<n,0<=P2<n )

The Input is ended by a 0.


If the clock can be opened, you must tell Lara "open it on the nth move!" or "Lara is trapped!"

Sample Input

1 1 1 1 1
0 4

1 2 3 4 5
0 3

2 2
0 1


Sample Output

open it on the 1th move!
open it on the 2th move!
Lara is traped!

Author: ZHOU, Feng
Source: ZOJ Monthly, December 2004
Submit    Status