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

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

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

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

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

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

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

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

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

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

l.s = e
l.q = h
l.z = d
l.o = i
e.q = d
h.t = l
i.z = e
i.q = e
a.z = e
a.q = e
d.t = l
assert d.t.o.q.txt == "e"