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

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

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

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

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

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

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

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

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