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

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

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

j = A("j")
n = B("n")
a = C("a")
l = B("l")
d = B("d")
k = A("k")
e = C("e")
c = A("c")
h = C("h")
f = C("f")

j.z = d
j.p = k
n.s = d
a.s = f
l.s = n
d.s = l
k.z = l
k.p = c
e.s = f
c.z = d
c.p = j
h.s = f
f.s = h
assert e.s.s.s.s.s.s.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.p: A = None
        self.txt = txt

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

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

j = A("j")
n = B("n")
a = C("a")
l = B("l")
d = B("d")
k = A("k")
e = C("e")
c = A("c")
h = C("h")
f = C("f")

j.z = d
j.p = k
n.s = d
a.s = f
l.s = n
d.s = l
k.z = l
k.p = c
e.s = f
c.z = d
c.p = j
h.s = f
f.s = h
assert e.s.s.s.s.s.s.s.s.txt == "h"