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

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

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

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

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

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

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

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

b.o = e
a.v = m
e.q = i
e.z = l
m.v = h
i.q = e
i.z = l
c.v = m
l.o = e
h.v = m
assert m.v.v.v.v.v.v.v.txt == "h"