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

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

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

d = A("d")
a = B("a")
e = C("e")

d.x = a
a.s = e
e.y = d
assert d.x.s.y.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.txt = txt

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

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

d = A("d")
a = B("a")
e = C("e")

d.x = a
a.s = e
e.y = d
assert d.x.s.y.txt == "d"