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

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

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

m = A("m")
i = B("i")
n = C("n")
k = B("k")

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

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

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

m = A("m")
i = B("i")
n = C("n")
k = B("k")

m.r = n
i.p = k
n.s = m
k.p = i
assert i.p.p.p.p.txt == "i"