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

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

b = A("b")
m = B("m")
n = B("n")
i = B("i")
e = B("e")
l = A("l")
k = A("k")
c = A("c")
g = B("g")

b.z = k
m.o = k
n.o = l
i.o = b
e.o = k
l.z = c
k.z = c
c.z = b
g.o = l
assert k.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.o: A = None
        self.txt = txt

b = A("b")
m = B("m")
n = B("n")
i = B("i")
e = B("e")
l = A("l")
k = A("k")
c = A("c")
g = B("g")

b.z = k
m.o = k
n.o = l
i.o = b
e.o = k
l.z = c
k.z = c
c.z = b
g.o = l
assert k.z.z.z.txt == "k"