시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 128 MB0000.000%

문제

A two dimensional square plate is located in a rectangular coordinate system so that its lower left corner coincides with the origin and upper right corner coincides with a point with integer coordinates.

Some points on the plate are marked. Each marked point has to be connected to a side of the plate by exactly one horizontal or vertical line. None of those lines can contain any other of given points on the plate and no two lines may intersect.

Write a program that will find described lines for given set of points on a plate so that the sum of their lengths will be minimal possible.

입력

The first line of input file consists of an integer A (2 ≤ A ≤ 30), length of a plate side.

The second line consists of an integer N (1 ≤ N ≤ 100), number of given points on the plate.

Each of the following N lines consists of two integers X and Y (1 ≤ X,Y ≤ A-1) determining coordinates of a point on the plate. There will be no two different lines consisting of the same pair of coordinates (i.e. no two points will coincide).

출력

The first line of output file should contain the sum of lengths of lines described above.

Each of the following N lines should contain one of the words 'GORE' (up), 'DOLJE' (down), 'LIJEVO' (left) or 'DESNO' (right) determining a side of the plate to which corresponding point is connected by a line.

If there are more than one solution, output any one.

 If a solution does not exist then first and only line should contain integer -1.

예제 입력 1

6
4
3 1
3 5
5 4
1 4

예제 출력 1

4
DOLJE
GORE
DESNO
LIJEVO

예제 입력 2

10
5
8 1
4 3
1 2
3 9
8 5

예제 출력 2

8
DOLJE
DOLJE
LIJEVO
GORE
DESNO

예제 입력 3

10
4
5 1
5 2
4 3
6 3

예제 출력 3

13
DOLJE
DESNO
DOLJE
DESNO