#2326 IP Converter

29  1 s   128 MB  

Description

A computer connected to the internet is identified by an IP address. The most common way of displaying an IP address is the dotted quad method: four eight-bit (0-255 in base ten) numbers separated by periods.

Someone has given you a possible IP address, but the periods have been removed, leaving only a string of digits. IP Converter with a method possible Addresses that takes a String ambiguous IP containing the digits and prints a String[] containing all the possible IP addresses that can be formed from those digits by inserting three periods to form a dotted quad.

The numbers in each of the four positions can have any integer value between zero and 255, inclusive. However, a number may not have leading zeroes. For example, the digits 1902426 can form 1.90.24.26, 19.0.24.26, 190.2.4.26, and other IP addresses. However, it cannot form 19.02.4.26.

Input

First line,  a number of test cases T( T <= 50)

Next line, ambiguous IP will contain between 1 and 50 characters.

Each character of ambiguous IP will be between '0' and '9', inclusive.

Output

Print value lexicographically, the elements of the all possible IP addresses, using their string ordering (the period character precedes all digit characters).

if you cannot find possible IP addresses, print the IMPOSSIBLE.

End of each test case, print the newline.

Sample Input

Sample Output

4
1902426
000
11111111
3082390871771742784899852251737850570843857369760
1.90.24.26
1.90.242.6
19.0.24.26
19.0.242.6
190.2.4.26
190.2.42.6
190.24.2.6

IMPOSSIBLE 

1.1.111.111
1.11.11.111
1.11.111.11
1.111.1.111
1.111.11.11
1.111.111.1
11.1.11.111
11.1.111.11
11.11.1.111
11.11.11.11
11.11.111.1
11.111.1.11
11.111.11.1
111.1.1.111
111.1.11.11
111.1.111.1
111.11.1.11
111.11.11.1
111.111.1.1

IMPOSSIBLE

Source

Topcoder Single Round Match 210 Round 1 - Division I, Level One