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

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

c = A("c")
b = B("b")
k = B("k")

c.r = b
c.z = k
b.p = k
b.o = k
k.p = b
k.o = b
assert k.p.p.o.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.z: B = None
        self.txt = txt

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

c = A("c")
b = B("b")
k = B("k")

c.r = b
c.z = k
b.p = k
b.o = k
k.p = b
k.o = b
assert k.p.p.o.txt == "b"