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

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

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

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

b.r = m
b.y = m
b.w = m
m.p = b
m.u = b
g.s = m
assert b.y.p.w.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.y: B = None
        self.w: B = None
        self.txt = txt

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

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

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

b.r = m
b.y = m
b.w = m
m.p = b
m.u = b
g.s = m
assert b.y.p.w.txt == "m"