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

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

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

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

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

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

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

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

b.x = m
m.r = g
g.w = b
assert b.x.r.w.txt == "b"