Prism Phase Locks
A planetarium contains rotating prisms. Each prism points to a phase mark on a circular dial containing the marks in clockwise order.
Prism has two mechanical locks. It must be placed at exactly one of the phases and . Let its selected phase be .
For two phase marks and , define their clockwise phase advance as
where the result is the unique integer in the range through . In particular, .
There are directed light channels. Channel starts at prism and ends at prism . It functions if and only if
Choose one of the two locks for every prism so that all directed light channels function. If this is impossible, report that no valid selection exists.
Input
The first line contains three integers , , and (, , ), the number of prisms, the number of directed channels, and the number of phase marks.
Output
If no selection satisfies every channel, print IMPOSSIBLE.
Otherwise, print integers , each equal to or . If , prism is locked at phase . If , it is locked at phase .
Samples
Sample 1
Input
3 3 12 1 7 3 9 5 11 1 2 2 2 2 3 2 2 3 1 8 8
Output
1 1 1
The printed selection uses phases , , and . The clockwise advances of the three channels are , , and , respectively, so every required interval is met.