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

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

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

m = A("m")
k = B("k")
b = C("b")
i = C("i")
h = B("h")
n = B("n")
c = C("c")
l = B("l")
e = A("e")
d = C("d")

m.z = i
k.y = d
b.o = e
i.o = m
h.y = b
n.y = c
c.o = m
l.y = d
e.z = i
d.o = e
assert n.y.o.z.o.z.o.z.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.txt = txt

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

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

m = A("m")
k = B("k")
b = C("b")
i = C("i")
h = B("h")
n = B("n")
c = C("c")
l = B("l")
e = A("e")
d = C("d")

m.z = i
k.y = d
b.o = e
i.o = m
h.y = b
n.y = c
c.o = m
l.y = d
e.z = i
d.o = e
assert n.y.o.z.o.z.o.z.txt == "i"