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

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

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

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

a.s = l
a.r = f
f.t = a
l.r = a
assert l.r.s.r.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.r: B = None
        self.txt = txt

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

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

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

a.s = l
a.r = f
f.t = a
l.r = a
assert l.r.s.r.txt == "a"