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

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

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

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

m = A("m")
d = B("d")
e = C("e")
i = D("i")
c = A("c")
h = C("h")
j = B("j")
n = B("n")

m.z = c
d.w = e
e.o = h
e.r = i
i.u = m
i.s = m
c.z = m
h.o = e
h.r = i
j.w = h
n.w = e
assert j.w.r.s.z.z.z.z.z.txt == "
class A:
    def __init__(self, txt: str):
        self.z: A = None
        self.txt = txt

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

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

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

m = A("m")
d = B("d")
e = C("e")
i = D("i")
c = A("c")
h = C("h")
j = B("j")
n = B("n")

m.z = c
d.w = e
e.o = h
e.r = i
i.u = m
i.s = m
c.z = m
h.o = e
h.r = i
j.w = h
n.w = e
assert j.w.r.s.z.z.z.z.z.txt == "c"