You are given several IPv4 CIDR blocks together with a collection of IPv4 addresses. For every queried address, determine whether it falls inside any of the provided CIDR blocks.
An IPv4 address is written as a.b.c.d, with each component taking an integer value from 0 through 255. CIDR notation uses the form ip/prefixLen; for instance, 192.168.1.0/24 covers IPv4 addresses whose first 24 bits match.
n
cidr_1
cidr_2
...
cidr_n
q
ip_1
ip_2
...
ip_q
n is the total number of CIDR blocks.n lines contains one CIDR string.q gives the number of address queries.q lines contains one IPv4 address.Produce one output line for every queried IP address:
YES when the address is included in at least one supplied CIDR block.NO when it is not included in any supplied CIDR block.1 <= n <= 2 * 10^51 <= q <= 2 * 10^50 <= prefixLen <= 32Input:
3
192.168.1.0/24
10.0.0.0/8
172.16.5.10/32
5
192.168.1.42
192.168.2.1
10.2.3.4
172.16.5.10
172.16.5.11
Output:
YES
NO
YES
YES
NO