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

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

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

c = A("c")
h = B("h")
i = C("i")
d = B("d")
a = B("a")
e = C("e")
k = C("k")
n = A("n")
j = C("j")
g = A("g")

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

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

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

c = A("c")
h = B("h")
i = C("i")
d = B("d")
a = B("a")
e = C("e")
k = C("k")
n = A("n")
j = C("j")
g = A("g")

c.z = g
c.s = a
h.u = a
i.s = n
i.p = k
d.u = a
a.u = h
e.s = c
e.p = k
k.s = c
k.p = e
n.z = c
n.s = h
j.s = n
j.p = i
g.z = n
g.s = h
assert c.s.u.u.u.txt == "h"