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

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

i = A("i")
k = B("k")
j = B("j")
b = A("b")
f = A("f")
n = A("n")
m = A("m")

i.x = n
k.o = m
k.z = j
j.o = f
j.z = k
b.x = i
f.x = m
n.x = f
m.x = b
assert b.x.x.x.x.x.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: A = None
        self.txt = txt

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

i = A("i")
k = B("k")
j = B("j")
b = A("b")
f = A("f")
n = A("n")
m = A("m")

i.x = n
k.o = m
k.z = j
j.o = f
j.z = k
b.x = i
f.x = m
n.x = f
m.x = b
assert b.x.x.x.x.x.x.x.txt == "n"