#C805. Valid IPv4 Address Checker

    ID: 51989 Type: Default 1000ms 256MiB

Valid IPv4 Address Checker

Valid IPv4 Address Checker

Given an input string representing an IPv4 address, determine whether it is valid or not.

An IPv4 address is valid if it consists of exactly four parts separated by dots ('.'). Each part must be a decimal number between 0 and 255 (inclusive) without leading zeros (except for the number 0 itself). The address "192.168.0.1" is valid, while "256.100.50.0" is invalid because 256 is out of range, and "123.045.067.089" is invalid because of the leading zeros.

Your task is to implement a checker that reads multiple test cases from standard input and outputs whether each provided IP address is valid.

Formally, an IPv4 address is valid if it meets the following conditions:

  • It is composed of four segments separated by .
  • Each segment is a number in the interval \( [0,255] \).
  • Each segment does not contain extra leading zeros. That is, for any segment, if its integer value is \( n \), then its string representation must be exactly \( n \) (in decimal form, without leading zeros) except if \( n = 0 \).

inputFormat

The first line contains an integer \( T \) representing the number of test cases.

Each of the next \( T \) lines contains a string representing an IPv4 address to be checked.

outputFormat

For each test case, output a single line containing either "True" if the IP address is valid or "False" if it is not.

## sample
5
192.168.0.1
255.255.255.255
256.100.50.0
123.045.067.089
192.168.1
True

True False False False

</p>