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

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

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

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

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

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

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

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

e.s = d
d.p = m
m.s = e
assert m.s.s.p.txt == "m"