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

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

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

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

a = A("a")
m = B("m")
k = C("k")
h = D("h")
n = B("n")
j = D("j")
g = C("g")
b = C("b")
e = B("e")

a.s = b
a.r = n
m.p = a
m.v = n
m.w = h
k.u = e
h.u = j
n.p = a
n.v = m
n.w = h
j.u = h
g.u = n
b.u = m
e.p = a
e.v = m
e.w = j
assert m.w.u.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.r: B = None
        self.txt = txt

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

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

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

a = A("a")
m = B("m")
k = C("k")
h = D("h")
n = B("n")
j = D("j")
g = C("g")
b = C("b")
e = B("e")

a.s = b
a.r = n
m.p = a
m.v = n
m.w = h
k.u = e
h.u = j
n.p = a
n.v = m
n.w = h
j.u = h
g.u = n
b.u = m
e.p = a
e.v = m
e.w = j
assert m.w.u.u.u.txt == "j"