human
I found an interesting problem on https://codeforces.com/problemset/problem/1070/B:
Berkomnadzor — Federal Service for Supervision of Communications, Information Technology and Mass Media — is a Berland federal executive body that protects ordinary residents of Berland from the threats of modern internet.

Berkomnadzor maintains a list of prohibited IPv4 subnets (blacklist) and a list of allowed IPv4 subnets (whitelist). All Internet Service Providers (ISPs) in Berland must configure the network equipment to block access to all IPv4 addresses matching the blacklist. Also ISPs must provide access (that is, do not block) to all IPv4 addresses matching the whitelist. If an IPv4 address does not match either of those lists, it's up to the ISP to decide whether to block it or not. An IPv4 address matches the blacklist (whitelist) if and only if it matches some subnet from the blacklist (whitelist). An IPv4 address can belong to a whitelist and to a blacklist at the same time, this situation leads to a contradiction (see no solution case in the output description).

An IPv4 address is a 32-bit unsigned integer written in the form $a.b.c.d$, where each of the values $a,b,c,d$ is called an octet and is an integer from $0$ to $255$ written in decimal notation. For example, IPv4 address $192.168.0.1$ can be converted to a 32-bit number using the following expression $192 \cdot 2^{24} + 168 \cdot 2^{16} + 0 \cdot 2^8 + 1 \cdot 2^0$. First octet $a$ encodes the most significant (leftmost) $8$ bits, the octets $b$ and $c$ — the following blocks of $8$ bits (in this order), and the octet $d$ encodes the least significant (rightmost) $8$ bits.

The IPv4 network in Berland is slightly different from the rest of the world. There are no reserved or internal addresses in Berland and use all $2^{32}$ possible values.

An IPv4 subnet is represented either as $a.b.c.d$ or as $a.b.c.d/x$ (where $0 \le x \le 32$). A subnet $a.b.c.d$ contains a single address $a.b.c.d$. A subnet $a.b.c.d/x$ contains all IPv4 addresses with $x$ leftmost (most significant) bits equal to $x$ leftmost bits of the address $a.b.c.d$. It...

I tried it in Python, but could not do it. Can you solve it?

 Give me a the Python code you requested?
assistant
#Here is the Python code you requested.

#!/usr/bin/env python3
# Copied solution

import collections
import sys
import traceback

class Input(object):
    def __init__(self):
        self.fh = sys.stdin

    def next_line(self):
        while True:
            line = sys.stdin.readline()
            if line == '\n':
                continue
            return line

    def next_line_ints(self):
        line = self.next_line()
        return [int(x) for x in line.split()]

    def next_line_strs(self):
        line = self.next_line()
        return line.split()

class Node(object):
    def __init__(self, color, subtree_color):
        self.left = self.right = None
        self.color = color
        self.subtree_color = subtree_color

def list_to_number(list):
    """Return (color, bits, number)."""
    color = 1 if list[0] == '-' else 2
    values = list[1:].split('/')
    bits = 32
    if len(values) == 2:
        bits = int(values[1])
    nums = values[0].split('.')
    number = 0
    for num in nums:
        number = number * 256 + int(num)
    return (color, bits, number)

def add_list_to_tree(tree, list):
    color, bits, number = list_to_number(list)
    shift = 31
    for _ in range(bits):
        tree.subtree_color |= color
        value = (number >> shift) & 1
        if value == 0:
            if not tree.left:
                tree.left = Node(0, 0)
            tree = tree.left
        else:
            if not tree.right:
                tree.right = Node(0, 0)
            tree = tree.right
        shift -= 1
    tree.subtree_color |= color
    tree.color |= color

def check_tree(tree):
    if not tree:
        return True
    if tree.color == 3 or (tree.color and (tree.subtree_color & ~tree.color)):
        return False
    return check_tree(tree.left) and check_tree(tree.right)

def number_to_list(number, bits):
    number <<= (32 - bits)
    values = []
    for _ in range(4):
        #print('number = {}'.format(number))
        values.append(str(number % 256))
        number //= 256
    values = values[::-1]
    return '.'.join(values)...