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

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

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

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

k = A("k")
l = B("l")
b = C("b")
d = D("d")
e = D("e")
h = C("h")
f = C("f")
m = D("m")

k.t = l
k.o = l
l.q = b
l.r = b
l.y = d
b.p = e
d.x = l
d.p = l
d.w = l
e.x = l
e.p = l
e.w = l
h.p = m
f.p = e
m.x = l
m.p = l
m.w = l
assert k.t.r.p.w.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.o: B = None
        self.txt = txt

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

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

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

k = A("k")
l = B("l")
b = C("b")
d = D("d")
e = D("e")
h = C("h")
f = C("f")
m = D("m")

k.t = l
k.o = l
l.q = b
l.r = b
l.y = d
b.p = e
d.x = l
d.p = l
d.w = l
e.x = l
e.p = l
e.w = l
h.p = m
f.p = e
m.x = l
m.p = l
m.w = l
assert k.t.r.p.w.txt == "l"