class A:
    def __init__(self, txt: str):
        self.y: A = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.v: A = None
        self.z: A = None
        self.txt = txt

b = A("b")
l = B("l")
n = A("n")
k = A("k")

b.y = n
l.v = k
l.z = n
n.y = b
k.y = b
assert k.y.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: A = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.v: A = None
        self.z: A = None
        self.txt = txt

b = A("b")
l = B("l")
n = A("n")
k = A("k")

b.y = n
l.v = k
l.z = n
n.y = b
k.y = b
assert k.y.y.y.txt == "b"