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

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

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

h = A("h")
m = B("m")
l = C("l")
i = A("i")
k = C("k")
a = A("a")
c = B("c")
f = C("f")
g = A("g")
d = A("d")

h.y = g
h.p = d
h.t = m
m.r = c
m.p = c
m.y = k
l.t = k
l.z = f
i.y = d
i.p = d
i.t = c
k.t = f
k.z = f
a.y = g
a.p = h
a.t = m
c.r = m
c.p = m
c.y = f
f.t = l
f.z = l
g.y = h
g.p = a
g.t = m
d.y = g
d.p = a
d.t = c
assert f.z.z.t.z.z.z.z.z.t.txt == "
class A:
    def __init__(self, txt: str):
        self.y: A = None
        self.p: A = None
        self.t: B = None
        self.txt = txt

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

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

h = A("h")
m = B("m")
l = C("l")
i = A("i")
k = C("k")
a = A("a")
c = B("c")
f = C("f")
g = A("g")
d = A("d")

h.y = g
h.p = d
h.t = m
m.r = c
m.p = c
m.y = k
l.t = k
l.z = f
i.y = d
i.p = d
i.t = c
k.t = f
k.z = f
a.y = g
a.p = h
a.t = m
c.r = m
c.p = m
c.y = f
f.t = l
f.z = l
g.y = h
g.p = a
g.t = m
d.y = g
d.p = a
d.t = c
assert f.z.z.t.z.z.z.z.z.t.txt == "l"