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

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

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

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

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

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

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

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

f.s = k
k.v = l
l.v = k
assert f.s.v.v.txt == "k"