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

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

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

g = A("g")
i = B("i")
b = C("b")

g.y = b
i.s = g
b.s = g
assert g.y.s.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.txt = txt

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

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

g = A("g")
i = B("i")
b = C("b")

g.y = b
i.s = g
b.s = g
assert g.y.s.y.txt == "b"