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

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

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

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

e = A("e")
c = B("c")
f = C("f")
h = D("h")
b = B("b")
m = A("m")
a = B("a")
k = C("k")

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

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

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

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

e = A("e")
c = B("c")
f = C("f")
h = D("h")
b = B("b")
m = A("m")
a = B("a")
k = C("k")

e.t = b
e.r = k
c.u = k
c.w = b
c.p = m
f.s = h
f.p = a
h.u = e
b.u = k
b.w = c
b.p = e
m.t = a
m.r = f
a.u = k
a.w = c
a.p = m
k.s = h
k.p = b
assert k.p.p.t.u.s.txt == "h"