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

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

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

l = A("l")
j = B("j")
b = C("b")

l.o = j
l.z = b
j.w = b
j.o = l
b.w = l
assert l.z.w.z.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.z: C = None
        self.txt = txt

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

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

l = A("l")
j = B("j")
b = C("b")

l.o = j
l.z = b
j.w = b
j.o = l
b.w = l
assert l.z.w.z.txt == "b"