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

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

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

c = A("c")
d = B("d")
b = C("b")

c.x = b
d.o = b
d.s = b
b.r = d
b.x = d
b.o = c
assert d.o.x.o.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.txt = txt

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

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

c = A("c")
d = B("d")
b = C("b")

c.x = b
d.o = b
d.s = b
b.r = d
b.x = d
b.o = c
assert d.o.x.o.txt == "b"