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

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

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

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

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

m = A("m")
h = B("h")
k = C("k")
j = D("j")
l = E("l")

m.z = h
h.r = m
h.p = m
h.t = l
k.p = l
k.s = l
k.x = j
k.t = h
j.o = k
j.r = k
l.p = k
assert l.p.s.p.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.txt = txt

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

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

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

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

m = A("m")
h = B("h")
k = C("k")
j = D("j")
l = E("l")

m.z = h
h.r = m
h.p = m
h.t = l
k.p = l
k.s = l
k.x = j
k.t = h
j.o = k
j.r = k
l.p = k
assert l.p.s.p.txt == "k"