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

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

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

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

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

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

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

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

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