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

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

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

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

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

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

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

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

a.t = l
a.s = m
f.v = a
l.z = a
l.p = f
l.w = f
m.z = a
m.p = f
m.w = f
assert l.p.v.t.p.txt == "f"