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

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

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

c = A("c")
l = B("l")
m = C("m")
i = C("i")

c.v = m
l.t = c
l.w = c
m.p = i
m.s = l
m.r = l
i.p = m
i.s = l
i.r = l
assert i.p.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.v: C = None
        self.txt = txt

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

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

c = A("c")
l = B("l")
m = C("m")
i = C("i")

c.v = m
l.t = c
l.w = c
m.p = i
m.s = l
m.r = l
i.p = m
i.s = l
i.r = l
assert i.p.p.p.txt == "m"