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

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

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

a = A("a")
l = B("l")
g = C("g")

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

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

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

a = A("a")
l = B("l")
g = C("g")

a.t = g
l.w = a
l.v = a
l.s = g
g.s = l
g.u = a
g.p = a
assert l.w.t.s.txt == "l"