Go Back
Cibin is confused between IPv4 and IPv6 (200)
Description

Its the subject Computer Networks and Cibin is confused between Ipv4 and Ipv6 addresses. His teacher solved his doubts and taught him about both.

Following were the points his teacher covered about Ipv4 addresses:
• An IPv4 address has the following format: x . x . x . x where x is called an octet and must be a decimal value between 0 and 255. Octets are separated by periods. An IPv4 address must contain three periods and four octets.
• No period should start with 0 unless the period has single digit.
• The following examples are valid Ipv4 Addresses:
192.168.0.1
10.0.0.5
1.2.3.4

Following were the points his teacher covered about Ipv6 addresses:
• In IPv6, addresses are expressed as a series of eight 4-character hexadecimal numbers, which represent 16 bits each (for a total of 128 bits).
• Leading zeroes MUST be suppressed. For example, 1:08:1:2:3:01:ab:5 is not acceptable and must be represented as 1:8:1:2:3:1:ab:5
• The characters "a", "b", "c", "d", "e", and "f" in an IPv6 address MUST be represented in lowercase.
• The following examples are valid Ipv6 Addresses:
3:ed2:5c0:d0ab:ef:9:2:f
2001:db8:0:1:1:1:1:1
Now, his teacher wants to check how much Cibin learnt from his efforts by taking a short assessment test.

Input

The first line of input contain an integer T denoting the number of test cases. Each test case consists of one line, which contains a string of address.

Output

For each test case, output a single line output as ipv4 / ipv6 / invalid.

Constraints

1 <= T <= 100

Example
Copy Input

Input:
4
192.168.43.75
2001:DB8:0111:2:1:1:1001:2008
2001:db8:1234:5678:2:1:56:45
192.168.AB.CD

Output:
ipv4
invalid
ipv6
invalid

Explanation

In test case 1, the address is a valid IPv4 address.
In test case 2, capital letters are used and 0 is not suppressed which makes it invalid IPv6 address.
In test case 3, the address is a valid IPv6 address.
In test case 4, the address is not a valid IPv4 address due to the usage of alphabets.

Single Round Match #05
3 hour contest



Announcement
Scoring will be 100-200-300.

Problem Tags
adhoc, strings

Supported by our Coding Partner