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

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

k = A("k")
d = B("d")
f = B("f")
n = B("n")

k.z = n
d.o = n
f.o = d
n.o = d
assert k.z.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.txt = txt

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

k = A("k")
d = B("d")
f = B("f")
n = B("n")

k.z = n
d.o = n
f.o = d
n.o = d
assert k.z.o.o.txt == "n"