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

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

a = A("a")
b = B("b")
i = B("i")
l = B("l")
n = B("n")
d = A("d")
f = B("f")
m = B("m")

a.o = d
b.z = f
i.z = l
l.z = f
n.z = i
d.o = a
f.z = l
m.z = i
assert d.o.o.o.o.o.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: A = None
        self.txt = txt

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

a = A("a")
b = B("b")
i = B("i")
l = B("l")
n = B("n")
d = A("d")
f = B("f")
m = B("m")

a.o = d
b.z = f
i.z = l
l.z = f
n.z = i
d.o = a
f.z = l
m.z = i
assert d.o.o.o.o.o.o.o.txt == "a"