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

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

l.t = c
l.s = c
l.w = i
h.o = l
c.q = l
i.o = l
f.o = l
assert h.o.w.o.t.txt == "
class A:
    def __init__(self, txt: str):
        self.t: C = None
        self.s: C = None
        self.w: B = 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.q: A = None
        self.txt = txt

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

l.t = c
l.s = c
l.w = i
h.o = l
c.q = l
i.o = l
f.o = l
assert h.o.w.o.t.txt == "c"