Milliseconds Clock

Time Limit: 10 Seconds    Memory Limit: 32768 KB

When you are working with synced cameras, like any other field, you need some extra utilities for testing purposes. One of these utilities, is a simple milliseconds clock. Why? Because sometimes you need to test the sync of the two cameras using a unique reference. Both cameras are put in front of the clock and start getting single shot frames.

Assuming the exposure time of the camera is 1 millisecond, the shutter may be open during two different milliseconds of the clock, which makes the taken frame's captured clock state, undecidable.

Your task is to determine what values where possible in a shown state of a three digit seven segment.

 

For example if a one digit seven segment was captured showing below states:

Input

The input consists of several test cases and ends with end-of-file

Each test case is represented in three lines and there is a blank line after each test case.

Each seven segment is written in a 3*3 character box, which makes each test case a 3*9 character box. Vertical segments will be given with “|” and horizontal segments will be given with “_”.

Output

For each test case, output all the possibilities one after another, in increasing order, separated by commas.

If there is no possible value, output “impossible

Sample Input

 _    _ 
| | | _|
|_| ||_ 
_     _ 
_||_||_ 
_|  | _|
 _      
|_  |  |
|_| |  |
_       
 |  |  |
 |  |  |
 _      
|_| |  |
|_| |  |
 _      
|_| |  |
 _| |  |
_  _    
_||_| _ 
_|  | _| 

Sample Output

012, 112, 712
115, 145, 315, 345, 715, 745
511, 611
111, 711
011, 111, 211, 311, 411, 511, 611, 711, 811, 911
111, 311, 411, 511, 711, 911
impossible
Submit

Source: 12th Iran Nationwide Internet Contest III