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

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

a = A("a")
h = B("h")
g = A("g")
i = B("i")
b = A("b")
c = B("c")
k = B("k")
f = B("f")
l = B("l")

a.o = f
h.z = k
g.o = c
i.z = f
b.o = k
c.z = h
k.z = l
f.z = h
l.z = c
assert f.z.z.z.z.z.z.z.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.txt = txt

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

a = A("a")
h = B("h")
g = A("g")
i = B("i")
b = A("b")
c = B("c")
k = B("k")
f = B("f")
l = B("l")

a.o = f
h.z = k
g.o = c
i.z = f
b.o = k
c.z = h
k.z = l
f.z = h
l.z = c
assert f.z.z.z.z.z.z.z.txt == "l"