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

class B:
    def __init__(self, txt: str):
        self.p: A = None
        self.o: A = None
        self.txt = txt

b = A("b")
j = B("j")
l = A("l")

b.z = l
j.p = l
j.o = l
l.z = b
assert l.z.z.z.txt == "
class A:
    def __init__(self, txt: str):
        self.z: A = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.p: A = None
        self.o: A = None
        self.txt = txt

b = A("b")
j = B("j")
l = A("l")

b.z = l
j.p = l
j.o = l
l.z = b
assert l.z.z.z.txt == "b"