class A:
    def __init__(self, txt: str):
        self.t: 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: B = None
        self.z: A = None
        self.x: B = None
        self.txt = txt

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

b.t = m
m.r = k
k.w = m
k.x = m
k.z = b
assert k.x.r.x.txt == "
class A:
    def __init__(self, txt: str):
        self.t: 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: B = None
        self.z: A = None
        self.x: B = None
        self.txt = txt

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

b.t = m
m.r = k
k.w = m
k.x = m
k.z = b
assert k.x.r.x.txt == "m"