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

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

c = A("c")
l = B("l")
e = B("e")

c.r = e
l.z = c
e.z = c
assert l.z.r.z.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.txt = txt

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

c = A("c")
l = B("l")
e = B("e")

c.r = e
l.z = c
e.z = c
assert l.z.r.z.txt == "c"