You have a robot in a two-dimensional labyrinth which consists of *N* × *M* cells. Some pairs of cells adjacent by side are separated by a wall or a door. The labyrinth itself is separated from the outside with walls around it. Some labyrinth cells are the exits. In order to leave the labyrinth the robot should reach any exit. There are keys in some cells. Any key can open any door but after the door is opened the key stays in the lock. Thus every key can be used only once. There are no labyrinth cells that contain both a key and an exit. Also there can not be both a wall and a door between the pair of adjacent cells.

Your need to write a program in *abc* language (see the language description below) that will lead the robot to one of the exits. Lets numerate the labyrinth rows from 0 to *N* - 1 top to bottom and the columns – from 0 to *M* - 1 left to right.

In *abc* language the following primary commands are available:
 -  move-DIR – move to the adjacent cell in the <img align="middle" class="tex-formula" src="https://espresso.codeforces.com/b141dfef648cb0749068acd4c95c8d2a280477f8.png" style="max-width: 100.0%;max-height: 100.0%;"/> direction. *down* increases the number of the row by 1, *right* increases the number of the column by 1. In case there’s a wall or a closed door in this direction, nothing’s happening. -  open-DIR – open the door between the current cell and the adjacent one in *DIR* direction. In case there isn’t any door in this direction or it’s already been opened or the robot doesn’t have a key, nothing’s happening.-  take – take the key in the current cell. In case there isn’t any key or the robot has already picked it up, nothing’s happening. The robot is able to carry any number of keys.-  terminate – terminate the program. This command is not obligatory to use. In case it’s absent the command is added at the end of the program automatically. 
Also, there are the following control commands in *abc* language: 
 -  for-N OPS end – repeat the sequence of the *OPS* commands *N* times, 0 &lt; *N* ≤ 100000. Each loop counter check counts as a command fulfilled by the robot. -  if-ok  OPS1  else  OPS2  endif – carries out the sequence of the *OPS*1 commands, if the previous command of moving, taking the key or opening the door was successful, otherwise the sequence of the *OPS*2 commands is being carried out. Should there be no previous command run, the sequence *OPS*1 will be carried out. If-ok check counts as a command fulfilled by the robot. -  break – stops the current *for* loop. -  continue – finishes the current *for* loop iterations. 
Note that the control and the primary commands can be fit into each other arbitrarily.

The robot will fulfill your commands sequentially until it exits the labyrinth, or it runs out of the commands, or the *terminate* command is run, or the quantity of the fulfilled commands exceeds the bound number 5·10<sup class="upper-index">6</sup>.

In *abc* language each command is a separate word and should be separated from other commands with at least one space symbol.

You should write a program that prints the sequence of commands leading the robot out of the labyrinth. Of course, as you are a good programmer, you should optimize these sequence.

The number of the non-space symbols in the sequence should not exceed 10<sup class="upper-index">7</sup>. If you succeed in finding the way out of the labyrinth *i* you’ll be granted the number of points equal to: 
 -  *W*<sub class="lower-index">*i*</sub> – labyrinth’s weight, some fixed constant. -  *G*<sub class="lower-index">*i*</sub> – number of robots moves. -  *O*<sub class="lower-index">*i*</sub> – number of fulfilled commands. Note that this number includes commands like *take* executed in the cells with no key, as well as opening commands applied to the already opened doors. -  *L*<sub class="lower-index">*i*</sub> – sequence length in symbols, excluding space symbols and line breaks. -  *Q* = 10·*N*·*M*. 
In case your sequence doesn’t lead the robot to the exit you’ll be granted 0 points. Your programs result will be the sum of all *S*<sub class="lower-index">*i*</sub>. You should maximize this total sum.

All labyrinths will be known and available to you. You can download the archive with labyrinths by any of the given links, password to extract files is aimtechiscool:
 1.  [https://drive.google.com/file/d/1dkIBfW_Gy6c3FJtXjMXZPMsGKRyn3pzp](https://drive.google.com/file/d/1dkIBfW_Gy6c3FJtXjMXZPMsGKRyn3pzp) 1.  [https://www.dropbox.com/s/77jrplnjgmviiwt/aimmaze.zip?dl=0](https://www.dropbox.com/s/77jrplnjgmviiwt/aimmaze.zip?dl=0) 1.  [https://yadi.sk/d/JNXDLeH63RzaCi](https://yadi.sk/d/JNXDLeH63RzaCi) 
In order to make local testing of your programs more convenient, the program calculating your results (checker) and the labyrinth visualizer will be available. This program is written in *python*3 programming language, that’s why you’re going to need *python*3 interpreter, as well as *pillow* library, which you can install with the following command pip3 install pillow. *pip*3 is a utility program for *python*3 package (library) installation. It will be installed automatically with the *python*3 interpreter.

Example command to run checker and visualizer: python3 aimmaze.py maze.in robot.abc --image maze.png. The checker can be run separately of visualization: python3 aimmaze.py maze.in robot.abc. Flag --output-log will let you see the information of robots each step: python3 aimmaze.py maze.in robot.abc --output-log. Note *python*3 can be installed as *python* on your computer.

To adjust image settings, you can edit constants at the beginning of the program *aimmaze*.*py*.
The first line contains integers *i*,  *W*,  *N*,  *M*,  *x*<sub class="lower-index">0</sub>,  *y*<sub class="lower-index">0</sub>,  *C*,  *D*,  *K*,  *E*. 
 -  1 ≤ *i* ≤ 14 – labyrinth’s number, which is needed for a checking program. -  1 ≤ *W* ≤ 10<sup class="upper-index">18</sup> – labyrinth’s weight, which is needed for a checking program. -  2 ≤ *N*, *M* ≤ 1000 – labyrinth’s height and width. -  0 ≤ *x*<sub class="lower-index">0</sub> ≤ *N* - 1,  0 ≤ *y*<sub class="lower-index">0</sub> ≤ *M* - 1 – robot’s starting position (*x*<sub class="lower-index">0</sub>, *y*<sub class="lower-index">0</sub>). -  0 ≤ *C* ≤ 2·*NM* – number of walls. -  0 ≤ *D* ≤ 10<sup class="upper-index">5</sup> – number of doors. -  0 ≤ *K* ≤ 10<sup class="upper-index">5</sup> – number of keys. -  1 ≤ *E* ≤ 1000 – number of exits. 
The *x* coordinate corresponds to the row number, *y* – to the column number. (0, 0) cell is located on the left-up corner, so that *down* direction increases the *x* coordinate, while *right* direction increases the *y* coordinate.

Each of the next *C* lines contains 4 integers each *x*<sub class="lower-index">1</sub>, *y*<sub class="lower-index">1</sub>, *x*<sub class="lower-index">2</sub>, *y*<sub class="lower-index">2</sub> – the coordinates of cells with a wall between them in a zero based indexing. It is guaranteed that |*x*<sub class="lower-index">1</sub> - *x*<sub class="lower-index">2</sub>| + |*y*<sub class="lower-index">1</sub> - *y*<sub class="lower-index">2</sub>| = 1,  0 ≤ *x*<sub class="lower-index">1</sub>, *x*<sub class="lower-index">2</sub> ≤ *N* - 1,  0 ≤ *y*<sub class="lower-index">1</sub>, *y*<sub class="lower-index">2</sub> ≤ *M* - 1. Also there are always walls around the labyrinth’s borders, which are not given in the labyrinths description.

Each of the next *D* lines contains door description in the same format as walls description. It is guaranteed that doors and walls don’t overlap.

Each of the next *K* rows contains a pair of integer which are the key coordinates in a zero based indexing.

Each of the next *E* rows contains a pair of integer which are the exit coordinates in a zero based indexing.

It is guaranteed that the robots starting position as well as keys and exits are located in pairwise different cells.
none
#include <iostream>
using namespace std;
 
int main() {
	string a = 
R"(
for-245
 move-right
 if-ok
    for-6
     take
     move-up
    end
    for-6
     move-down
    end
        move-left
        move-down
  else move-down
 endif
end
 
for-254
 move-right 
 if-ok 
    for-250
	for-13
		take 
		open-up 
		move-up 
	end
 
  	move-right
 
	for-13
		take 
		open-down
		move-down 
	end
	move-right
    end
    
    for-250
	for-13
		move-up
	end
 
  	move-left
 
	for-13 
		move-down
	end
	move-left
    end
    move-down  
  
 else move-down 
 endif 
end
 
for-438
 move-right
end
 for-70
   open-right
   move-right
 end
	)";
 
	cout << a;
	
	return 0;
}