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

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

a = A("a")
f = B("f")
e = B("e")
j = A("j")
m = B("m")
c = B("c")
i = B("i")

a.o = j
a.z = j
f.x = m
f.z = m
e.x = c
e.z = f
j.o = a
j.z = a
m.x = i
m.z = e
c.x = m
c.z = m
i.x = c
i.z = c
assert f.x.x.x.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.o: A = None
        self.z: A = None
        self.txt = txt

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

a = A("a")
f = B("f")
e = B("e")
j = A("j")
m = B("m")
c = B("c")
i = B("i")

a.o = j
a.z = j
f.x = m
f.z = m
e.x = c
e.z = f
j.o = a
j.z = a
m.x = i
m.z = e
c.x = m
c.z = m
i.x = c
i.z = c
assert f.x.x.x.x.x.txt == "i"