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

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

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

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

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

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

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

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

k.y = d
b.s = d
b.x = d
b.o = k
d.r = k
d.s = b
assert b.x.s.o.txt == "k"