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

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

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

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

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

a.p = e
e.r = l
m.z = e
m.s = a
m.w = a
l.p = j
l.t = e
l.u = a
j.p = l
j.t = e
j.u = a
d.p = j
d.t = e
d.u = a
assert a.p.r.t.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.txt = txt

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

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

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

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

a.p = e
e.r = l
m.z = e
m.s = a
m.w = a
l.p = j
l.t = e
l.u = a
j.p = l
j.t = e
j.u = a
d.p = j
d.t = e
d.u = a
assert a.p.r.t.txt == "e"