시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
5 초 512 MB 4 1 1 33.333%

문제

An IP (Internet Protocol) address is a number that is assigned to each device on the Internet. At the time being, most devices use version four of this protocol (IPv4). An IPv4 address is a 32-bit string. IPv4 addresses are normally represented in dot-decimal notation, which consists of four decimal numbers called octets, each ranging from 0 to 255 (inclusive), separated by dots, e.g., 172.16.254.1. Each octet represents a group of 8 bits (one byte) of the address. The first 8 bits of the string (when interpreted as an unsigned integer, with the most significant bit first) form the first octet, the next 8 bits form the second octet, and so on.

A subnet is normalized if the bits of the address other than the prefix are all zeroes. For example, 10.8.1.0/24 and 10.8.1.2/24 represent the same subnet, but 10.8.1.0/24 is normalized. The normalization of 255.255.255.255/13 is 255.248.0.0/13.

You will be given a list of subnet addresses, and you must output the shortest ordered list of subnets such that all the addresses are normalized and an address belongs to some subnet in the input if and only if it belongs to some subnet in the output.

입력

The first line of the input gives the number of test cases, TT test cases follow. Each begins with one line with an integer N, the number of subnets, and is followed by N more lines, each of which has a subnet addresses. Each subnet address is of the form A.B.C.D/P, where A, B, C, and D are integers from 0 to 255, inclusive, and P is an integer from 0 to 32, inclusive. No integer (apart from 0) has leading zeroes.

• 1 ≤ T ≤ 50.
• 1 ≤ N ≤ 10.

출력

For each test case, output one line containing "Case #x:", where x is the test case number (starting from 1). Then output a list of subnet addresses, one per line, meeting the conditions described above. These addresses must be normalized and must be ordered. An address X comes before another address Y if X's first integer is smaller than Y's first integer, or if X and Y have the same first integer but X's second integer is smaller than Y's second integer, and so on.

Note that the requirements of the problem guarantee that there is a single unique answer for each test case.

예제 입력 1

3
2
10.1.2.3/8
10.2.3.4/17
2
10.2.3.4/9
10.128.2.3/9
10
224.147.224.186/18
58.45.85.53/14
52.56.134.139/26
52.227.82.227/22
83.250.251.44/13
83.250.12.64/16
58.40.52.11/14
52.22.138.56/23
238.223.58.151/27
58.32.52.11/13

예제 출력 1

Case #1:
10.0.0.0/8
Case #2:
10.0.0.0/8
Case #3:
52.22.138.0/23
52.56.134.128/26
52.227.80.0/22
58.32.0.0/12
83.248.0.0/13
224.147.192.0/18
238.223.58.128/27

채점

• 예제는 채점하지 않는다.