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

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

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

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

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

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

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

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

b.s = a
b.w = a
g.o = a
g.w = b
a.u = b
assert g.o.u.s.txt == "a"