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

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

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

h = A("h")
f = B("f")
l = C("l")

h.r = l
f.o = h
l.t = f
l.w = f
assert f.o.r.w.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.txt = txt

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

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

h = A("h")
f = B("f")
l = C("l")

h.r = l
f.o = h
l.t = f
l.w = f
assert f.o.r.w.txt == "f"