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

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

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

class D:
    def __init__(self, txt: str):
        self.o: C = None
        self.z: C = None
        self.txt = txt

a = A("a")
k = B("k")
l = C("l")
b = D("b")

a.o = b
k.t = l
k.r = a
l.y = b
b.o = l
b.z = l
assert l.y.z.y.z.txt == "
class A:
    def __init__(self, txt: str):
        self.o: D = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.o: C = None
        self.z: C = None
        self.txt = txt

a = A("a")
k = B("k")
l = C("l")
b = D("b")

a.o = b
k.t = l
k.r = a
l.y = b
b.o = l
b.z = l
assert l.y.z.y.z.txt == "l"