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

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

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

b.r = m
m.u = k
m.z = b
k.u = m
k.z = b
assert k.z.r.u.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.txt = txt

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

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

b.r = m
m.u = k
m.z = b
k.u = m
k.z = b
assert k.z.r.u.txt == "k"