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

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

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

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

h = A("h")
l = B("l")
i = C("i")
e = D("e")
b = C("b")
d = A("d")

h.y = e
l.o = i
i.z = e
e.z = b
e.t = b
b.z = e
d.y = e
assert i.z.z.z.txt == "
class A:
    def __init__(self, txt: str):
        self.y: D = None
        self.txt = txt

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

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

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

h = A("h")
l = B("l")
i = C("i")
e = D("e")
b = C("b")
d = A("d")

h.y = e
l.o = i
i.z = e
e.z = b
e.t = b
b.z = e
d.y = e
assert i.z.z.z.txt == "e"