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

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

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

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

m = A("m")
l = B("l")
a = C("a")
h = D("h")
b = C("b")
f = D("f")
d = D("d")
i = C("i")
c = B("c")

m.s = b
l.s = d
a.o = f
h.q = a
h.r = b
h.w = f
b.o = f
f.q = a
f.r = b
f.w = h
d.q = a
d.r = b
d.w = f
i.o = d
c.s = h
assert a.o.q.o.w.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.txt = txt

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

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

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

m = A("m")
l = B("l")
a = C("a")
h = D("h")
b = C("b")
f = D("f")
d = D("d")
i = C("i")
c = B("c")

m.s = b
l.s = d
a.o = f
h.q = a
h.r = b
h.w = f
b.o = f
f.q = a
f.r = b
f.w = h
d.q = a
d.r = b
d.w = f
i.o = d
c.s = h
assert a.o.q.o.w.w.w.txt == "h"