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 \(0\) and \(255\), inclusive.
Ranges of IP addresses can be formatted in the form \(x-y\), where \(x\) and \(y\) are IP addresses. IP ranges are inclusive.
An IP address \(x\) is less than an IP address \(y\) only when:
- \(x.a < y.a\) OR
- \(x.a = y.a\) and \(x.b < y.b\) OR
- \(x.a = y.a\) and \(x.b = y.b\) and \(x.c < y.c\) OR
- \(x.a = y.a\) and \(x.b = y.b\) and \(x.c = y.x\) and \(x.d < y.d\)
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, \(N\ (1 \le N \le 100)\). \(N\) 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 188.8.131.52-184.108.40.206 220.127.116.11-18.104.22.168 22.214.171.124-126.96.36.199 188.8.131.52