#C12130. IPv4 Address Filter

    ID: 41524 Type: Default 1000ms 256MiB

IPv4 Address Filter

IPv4 Address Filter

You are given a list of strings, each representing an IPv4 address. Your task is to filter out and print only the valid IPv4 addresses.

An IPv4 address is composed of four segments separated by dots. Each segment must be a decimal number in the range \(0 \leq x \leq 255\). In other words, an IP \(a.b.c.d\) is valid if and only if:

  • It contains exactly 4 parts separated by a dot.
  • Each part is a non-negative integer and lies between 0 and 255 inclusive.

Note that numbers with leading zeros (e.g. "01") are allowed and should be interpreted as their integer value.

inputFormat

The input is given via stdin and consists of multiple lines:

  1. The first line contains an integer \(n\), the number of IP addresses.
  2. The following \(n\) lines each contain a string representing an IPv4 address.

outputFormat

Output via stdout the valid IPv4 addresses, one per line, in the same order as they appear in the input.

## sample
6
192.168.0.1
256.256.256.256
10.0.0.123
192.168.1
172.16.254.0
172.316.254.0
192.168.0.1

10.0.0.123 172.16.254.0

</p>