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

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

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

g = A("g")
i = B("i")
f = C("f")
n = A("n")
e = B("e")
j = C("j")
m = A("m")
a = B("a")
c = C("c")

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

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

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

g = A("g")
i = B("i")
f = C("f")
n = A("n")
e = B("e")
j = C("j")
m = A("m")
a = B("a")
c = C("c")

g.z = e
i.p = e
i.t = g
i.s = c
f.u = e
n.z = e
e.p = a
e.t = n
e.s = f
j.u = i
m.z = a
a.p = e
a.t = n
a.s = c
c.u = i
assert c.u.s.u.t.z.p.p.txt == "e"