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

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

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

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

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

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

a.z = i
l.v = g
b.z = i
g.z = a
h.z = g
d.v = b
c.v = e
i.z = h
e.z = i
assert g.z.z.z.z.z.z.z.z.z.txt == "a"