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

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

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

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

l.s = k
i.p = l
k.p = i
assert k.p.p.s.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.txt = txt

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

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

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

l.s = k
i.p = l
k.p = i
assert k.p.p.s.txt == "k"