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

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

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

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

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

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

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

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

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

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

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