- 27

## Learning Opportunities

This puzzle can be solved using the following concepts. Practice using these concepts and improve your skills.

## Statement

## Goal

John's boss asked him to provision some networks for the company. John is an experienced network engineer, so the problem should be pretty straightforward. However, it was late at night, and he had a bit too much to drink, so he messed up a few of the numbers. Please help John fix the problem!A CIDR range consists of a prefix and a suffix. The prefix consists of four 8-bit numbers

`B`separated by a dot, which represents a 32-bit IP address. For example,

`S`between 0 and 32 inclusive, which tells us how many bits are fixed, counting from the left. This means that the remaining bits are variable. These bits determine the number of addresses

`N`available to the CIDR range.

The prefix and the suffix are separated by a forward slash. An example of a CIDR range is

A CIDR range is valid if all of the variable bits are 0.

For example:

11000000 . 10101000 . 00000010 .

**00000000**

11000000 . 10101000 . 0000

**1010 . 00000000**

We can fix it by changing the above CIDR range to

11000000 . 10101000 . 0000101

**0 . 00000000**

Given a

`M`number of CIDR ranges, validate each range and print the result. If a range is

Input

**Line 1:**An integer

`M`for the number of CIDR ranges

**Next**CIDR range

`M`lines:Output

If the CIDR range is valid, print valid , and then print

If the CIDR range is invalid, printinvalid , the new CIDR range, and then

`N`for the number of addressesIf the CIDR range is invalid, print

`N`for the number of addresses of the new range.Constraints

1 <=

0 <=

0 <=

1 <=

`M`<= 50 <=

`B`<= 2550 <=

`S`<= 321 <=

`N`<= 4294967296Example

Input

4 10.0.0.32/32 10.0.0.32/30 10.0.0.32/28 10.0.0.32/26

Output

valid 1 valid 4 valid 16 invalid 10.0.0.32/27 32

A higher resolution is required to access the IDE