eolymp
bolt
Try our new interface for solving problems
Problems

Genetic Code

Genetic Code

The connections between mathematics and biology are complicated. Most of the time they do not run along nice-looking links that merrily join at first glance, but they are abstract and not always easily established. Lake Vostok - about \textbf{14000} square kilometers large, up to \textbf{650} meters deep, and covered by \textbf{3743} meters of ice - was recently discovered on the Antarctic continent. The lake remained under conditions of high pressure and no sunlight for several millions of years. It is believed that ordinary life has evolved to a more efficient form using a genetic code composed of only three bases (the current state of ignorance proclaims the four bases adenine, cytosine, guanine, and thymine). Until reasonable names are found, the three bases will be abbreviated as \textbf{N}, \textbf{O}, and \textbf{P}. Moreover, the genome is single-stranded and directed, i.e., we may see it as a sequence over the alphabet \textit{\{}\textbf{N}, \textbf{O}, \textbf{P}\textit{\}}. Unless risking instability, it is necessary that the genome is a Thue-sequence, due to the Norwegian mathematician A. Thue (1863-1922). Define a subsegment of a sequence to be a connected subsequence, and call two subsegments adjacent if one follows immediately after the other in the sequence. A Thue-sequence is a sequence where no adjacent subsegments are equal. For example, \textbf{NOPNO} is and \textbf{NOPNPNO} is not a Thue-sequence, so that the first may be a genome whereas the second may not. To be able to simulate experiments with the new genomes, you are asked to generate genomes of certain lengths. \InputFile The input contains several test cases. Each test case consists of an integer \textbf{n}. You may assume that \textbf{1} ≤ \textbf{n} ≤ \textbf{5000}. The last test case is followed by a zero. \OutputFile For each test case specified by \textbf{n} output on a single line any genome of length \textbf{n}. If no genome of length \textbf{n} exists, output a blank line instead.
Time limit 8 seconds
Memory limit 64 MiB
Input example #1
1
2
10
20
0
Output example #1
N
NO
NONPNOPNPO
NONPNOPNPONOPNONPNOP