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

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

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

e = A("e")
k = B("k")
d = C("d")
h = A("h")
m = B("m")
n = A("n")
c = C("c")
b = A("b")
l = A("l")
j = B("j")

e.p = b
e.z = c
e.y = k
k.r = c
d.r = m
h.p = e
h.z = d
h.y = j
m.r = d
n.p = b
n.z = d
n.y = j
c.r = j
b.p = l
b.z = d
b.y = m
l.p = h
l.z = c
l.y = j
j.r = d
assert l.p.p.z.r.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.p: A = None
        self.z: C = None
        self.y: B = None
        self.txt = txt

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

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

e = A("e")
k = B("k")
d = C("d")
h = A("h")
m = B("m")
n = A("n")
c = C("c")
b = A("b")
l = A("l")
j = B("j")

e.p = b
e.z = c
e.y = k
k.r = c
d.r = m
h.p = e
h.z = d
h.y = j
m.r = d
n.p = b
n.z = d
n.y = j
c.r = j
b.p = l
b.z = d
b.y = m
l.p = h
l.z = c
l.y = j
j.r = d
assert l.p.p.z.r.r.r.txt == "m"