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

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

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

h = A("h")
g = B("g")
i = C("i")
e = A("e")
f = C("f")
l = B("l")
b = B("b")
m = A("m")

h.p = m
h.z = e
g.u = f
g.y = l
i.t = b
i.o = f
e.p = m
e.z = m
f.t = b
f.o = i
l.u = f
l.y = g
b.u = i
b.y = g
m.p = h
m.z = h
assert e.z.z.z.p.p.p.z.txt == "
class A:
    def __init__(self, txt: str):
        self.p: A = None
        self.z: A = None
        self.txt = txt

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

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

h = A("h")
g = B("g")
i = C("i")
e = A("e")
f = C("f")
l = B("l")
b = B("b")
m = A("m")

h.p = m
h.z = e
g.u = f
g.y = l
i.t = b
i.o = f
e.p = m
e.z = m
f.t = b
f.o = i
l.u = f
l.y = g
b.u = i
b.y = g
m.p = h
m.z = h
assert e.z.z.z.p.p.p.z.txt == "h"