class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.u: B = None
        self.w: B = None
        self.txt = txt

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

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

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

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

d.q = l
d.u = l
d.w = l
l.q = e
l.z = h
l.y = h
e.p = h
h.t = d
i.p = h
assert h.t.q.z.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.u: B = None
        self.w: B = None
        self.txt = txt

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

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

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

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

d.q = l
d.u = l
d.w = l
l.q = e
l.z = h
l.y = h
e.p = h
h.t = d
i.p = h
assert h.t.q.z.txt == "h"