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

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

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

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

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

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

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

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

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

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

e.p = j
h.w = n
h.r = d
i.u = e
n.w = b
n.y = j
n.u = i
k.u = m
d.u = e
j.w = n
j.r = k
b.u = e
m.p = h
a.w = n
a.r = b
assert j.r.u.p.w.w.txt == "b"