Baltic Olympiad in Informatics: 2014 Day 1, Problem 2

Three friends like to play the following game. The first friend chooses a string
Given the string
Constraints
Subtask 1 [35%]
Subtask 2 [65%]
No additional constraints.
Input Specification
The only line of input contains the string
Output Specification
Your program should print the original string
- If the final string
could not have been created using the above procedure, you should printNOT POSSIBLE
. - If the original string
is not unique, you should printNOT UNIQUE
.
Sample Input 1
Copy
ABXCABC
Sample Output 1
Copy
ABC
Sample Input 2
Copy
ABCDEF
Sample Output 2
Copy
NOT POSSIBLE
Sample Input 3
Copy
ABABABABA
Sample Output 3
Copy
NOT UNIQUE
Comments