class A:
    def __init__(self, txt: str):
        self.w: 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.u: D = None
        self.p: D = None
        self.txt = txt

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

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

e.w = m
f.q = i
a.u = m
a.p = m
m.t = f
i.u = m
i.p = m
l.q = a
d.w = m
assert e.w.t.q.p.t.q.txt == "
class A:
    def __init__(self, txt: str):
        self.w: 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.u: D = None
        self.p: D = None
        self.txt = txt

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

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

e.w = m
f.q = i
a.u = m
a.p = m
m.t = f
i.u = m
i.p = m
l.q = a
d.w = m
assert e.w.t.q.p.t.q.txt == "i"