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

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

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

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

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

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

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

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

e.r = d
d.y = e
a.y = e
assert e.r.y.r.txt == "d"