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

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

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

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

d = A("d")
b = B("b")
n = C("n")
j = D("j")
h = C("h")
m = C("m")
f = D("f")
l = D("l")
a = C("a")

d.u = j
d.w = j
b.z = h
n.s = j
j.z = b
j.p = m
j.u = l
h.s = j
m.s = f
f.z = b
f.p = a
f.u = l
l.z = b
l.p = m
l.u = f
a.s = j
assert n.s.p.s.p.s.p.txt == "
class A:
    def __init__(self, txt: str):
        self.u: D = None
        self.w: D = None
        self.txt = txt

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

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

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

d = A("d")
b = B("b")
n = C("n")
j = D("j")
h = C("h")
m = C("m")
f = D("f")
l = D("l")
a = C("a")

d.u = j
d.w = j
b.z = h
n.s = j
j.z = b
j.p = m
j.u = l
h.s = j
m.s = f
f.z = b
f.p = a
f.u = l
l.z = b
l.p = m
l.u = f
a.s = j
assert n.s.p.s.p.s.p.txt == "m"