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

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

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

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

a.p = g
h.w = e
h.o = g
c.t = g
c.z = e
m.t = g
m.z = a
b.t = h
b.z = e
i.t = h
i.z = e
l.t = g
l.z = e
e.p = h
g.w = e
g.o = h
assert m.t.o.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.txt = txt

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

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

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

a.p = g
h.w = e
h.o = g
c.t = g
c.z = e
m.t = g
m.z = a
b.t = h
b.z = e
i.t = h
i.z = e
l.t = g
l.z = e
e.p = h
g.w = e
g.o = h
assert m.t.o.o.o.txt == "h"