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

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

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

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

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

a.z = l
a.o = e
e.z = i
e.s = l
e.x = d
i.t = a
i.p = d
l.p = d
d.z = l
d.o = e
assert d.z.p.o.s.txt == "
class A:
    def __init__(self, txt: str):
        self.z: D = None
        self.o: B = None
        self.txt = txt

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

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

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

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

a.z = l
a.o = e
e.z = i
e.s = l
e.x = d
i.t = a
i.p = d
l.p = d
d.z = l
d.o = e
assert d.z.p.o.s.txt == "l"