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

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

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

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

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

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

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

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

g.r = f
g.u = c
g.w = c
f.o = g
c.y = f
assert c.y.o.w.txt == "c"