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.s: A = None
        self.txt = txt

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

b.r = h
l.o = b
h.t = l
h.s = b
assert h.t.o.r.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.s: A = None
        self.txt = txt

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

b.r = h
l.o = b
h.t = l
h.s = b
assert h.t.o.r.txt == "h"