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

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

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

d = A("d")
c = B("c")
e = C("e")
b = C("b")
n = B("n")
m = C("m")
a = B("a")
j = C("j")
i = C("i")
l = C("l")

d.w = e
c.r = e
e.w = b
e.z = a
b.w = j
b.z = a
n.r = i
m.w = i
m.z = n
a.r = e
j.w = e
j.z = c
i.w = e
i.z = n
l.w = i
l.z = a
assert l.w.z.r.w.z.r.z.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.txt = txt

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

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

d = A("d")
c = B("c")
e = C("e")
b = C("b")
n = B("n")
m = C("m")
a = B("a")
j = C("j")
i = C("i")
l = C("l")

d.w = e
c.r = e
e.w = b
e.z = a
b.w = j
b.z = a
n.r = i
m.w = i
m.z = n
a.r = e
j.w = e
j.z = c
i.w = e
i.z = n
l.w = i
l.z = a
assert l.w.z.r.w.z.r.z.txt == "a"