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

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

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

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

l.t = a
a.r = l
m.p = l
k.p = l
assert l.t.r.t.r.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.txt = txt

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

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

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

l.t = a
a.r = l
m.p = l
k.p = l
assert l.t.r.t.r.txt == "l"