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

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

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

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

l.s = f
m.s = k
k.r = l
f.s = l
assert f.s.s.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.s: A = None
        self.txt = txt

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

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

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

l.s = f
m.s = k
k.r = l
f.s = l
assert f.s.s.s.s.txt == "f"