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

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

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

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

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

e.q = l
m.u = i
i.u = m
i.x = m
i.w = j
j.r = m
d.q = b
l.r = m
b.r = m
assert l.r.u.w.r.txt == "
class A:
    def __init__(self, txt: str):
        self.q: D = None
        self.txt = txt

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

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

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

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

e.q = l
m.u = i
i.u = m
i.x = m
i.w = j
j.r = m
d.q = b
l.r = m
b.r = m
assert l.r.u.w.r.txt == "m"