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

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

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

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

f.u = a
g.w = f
a.y = g
assert a.y.w.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.txt = txt

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

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

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

f.u = a
g.w = f
a.y = g
assert a.y.w.u.txt == "a"