class A:
    def __init__(self, txt: str):
        self.w: C = 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.r: B = None
        self.txt = txt

e = A("e")
d = B("d")
f = C("f")
i = C("i")

e.w = f
d.s = e
f.r = d
i.r = d
assert e.w.r.s.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = 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.r: B = None
        self.txt = txt

e = A("e")
d = B("d")
f = C("f")
i = C("i")

e.w = f
d.s = e
f.r = d
i.r = d
assert e.w.r.s.w.txt == "f"