#P1446E. Long Recovery

    ID: 1061 Type: RemoteJudge 3000ms 256MiB Tried: 0 Accepted: 0 Difficulty: (None) Uploaded By: Tags>constructive algorithmsdfs and similar*3500

Long Recovery

No submission language available for this problem.

Description

A patient has been infected with an unknown disease. His body can be seen as an infinite grid of triangular cells which looks as follows:

Two cells are neighboring if they share a side. Therefore, each cell (xx, yy) has exactly three neighbors:

  • (x+1x+1, yy)
  • (x1x-1, yy)
  • (x+1x+1, y1y-1) if xx is even and (x1x-1, y+1y+1) otherwise.

Initially some cells are infected, all the others are healthy. The process of recovery begins. Each second, for exactly one cell (even though there might be multiple cells that could change its state) one of the following happens:

  • A healthy cell with at least 22 infected neighbors also becomes infected.
  • An infected cell with at least 22 healthy neighbors also becomes healthy.

If no such cell exists, the process of recovery stops. Patient is considered recovered if the process of recovery has stopped and all the cells are healthy.

We're interested in a worst-case scenario: is it possible that the patient never recovers, or if it's not possible, what is the maximum possible duration of the recovery process?

The first line contains one integer nn (1n250000)(1 \leq n \leq 250000)  — the number of infected cells.

The ii-th of the next nn lines contains two space-separated integers xix_i and yiy_i (0xi,yi<500)(0 \leq x_i, y_i < 500), meaning that cell (xi,yi)(x_i, y_i) is infected. All cells (xi,yi)(x_i, y_i) are distinct, and all other cells are considered healthy.

If it is possible that the organism never fully recovers from the disease, print SICK. Otherwise, you should print RECOVERED and in the next line an integer kk  — the longest possible recovery period, modulo 998244353998244353.

Input

The first line contains one integer nn (1n250000)(1 \leq n \leq 250000)  — the number of infected cells.

The ii-th of the next nn lines contains two space-separated integers xix_i and yiy_i (0xi,yi<500)(0 \leq x_i, y_i < 500), meaning that cell (xi,yi)(x_i, y_i) is infected. All cells (xi,yi)(x_i, y_i) are distinct, and all other cells are considered healthy.

Output

If it is possible that the organism never fully recovers from the disease, print SICK. Otherwise, you should print RECOVERED and in the next line an integer kk  — the longest possible recovery period, modulo 998244353998244353.

Samples

Sample Input 1

4
0 0
1 0
2 0
0 1

Sample Output 1

RECOVERED
4

Sample Input 2

3
1 0
3 0
1 1

Sample Output 2

SICK

Note

For the first testcase, the following drawings describe the longest possible recovery process. It can be proven that there are no recovery periods of length 55 or longer, and the organism always recovers in this testcase.

\hspace{40pt} \downarrow \hspace{40pt} \downarrow \hspace{40pt} \downarrow \hspace{40pt} \downarrow

\hspace{15pt} RECOVERED

For the second testcase, it is possible for the cells (2,0)(2, 0), (2,1)(2, 1), (0,1)(0, 1) to become infected. After that, no cell can change its state, so the answer is SICK, as not all of the cells are healthy.