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

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

c = A("c")
b = B("b")
l = B("l")
e = B("e")
g = B("g")
f = A("f")

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

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

c = A("c")
b = B("b")
l = B("l")
e = B("e")
g = B("g")
f = A("f")

c.z = f
c.o = b
b.s = c
l.s = f
e.s = f
g.s = f
f.z = c
f.o = l
assert b.s.z.o.s.txt == "f"