LearnPy Hub
← Regular Expressions problems
Hard

Valid IPv4 Addresses

An IPv4 address is four numbers 0–255 separated by dots, with no leading zeros (0 is fine, 01 is not). Build one regex for a single part — 25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d — and use it to fullmatch the whole address. Read lines and print Valid or Invalid for each.

Input

n, then n lines.

Output

n lines.

Sample 1

Input
4
192.168.0.1
256.1.1.1
10.0.0.01
0.0.0.0
Output
Valid
Invalid
Invalid
Valid

Sample 2

Input
1
255.255.255.255
Output
Valid
solution.py
Output appears here
Valid IPv4 Addresses · Python practice problem · LearnPy Hub