In computer networking, IPs allow you to reach another computer by an address.
Currently, the main standard for IP addresses is called IPv4. IPv4 addresses are formatted with four blocks in form
a.b.c.d, each block can only contain values between and , inclusive.
Ranges of IP addresses can be formatted in the form , where and are IP addresses. IP ranges are inclusive.
An IP address is less than an IP address only when:
- and OR
- and and OR
- and and and
in this order.
Evan notices that certain IP ranges often cause trouble on his servers, so he wants to block them.
Can you write a program for Evan that checks if a given IP is in a list of ranges?
The first line of input provides the number of IP ranges, . IP ranges follow. All IP ranges will be valid IP ranges, and will end with an IP larger than the start IP, as defined in the problem statement.
The final line is the IP address that Evan wants to test.
The output will be
bad ip if the IP is in any of the ranges or
good ip if it is not in any range.
3 22.214.171.124-126.96.36.199 188.8.131.52-184.108.40.206 220.127.116.11-18.104.22.168 22.214.171.124