class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.p: B = 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.y: B = None
        self.txt = txt

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

d.s = e
d.p = e
e.s = d
a.y = e
assert e.s.p.s.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.p: B = 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.y: B = None
        self.txt = txt

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

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