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

a = A("a")
c = B("c")
l = A("l")
i = A("i")

a.r = c
c.z = a
l.r = c
i.r = c
assert c.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

a = A("a")
c = B("c")
l = A("l")
i = A("i")

a.r = c
c.z = a
l.r = c
i.r = c
assert c.z.r.z.txt == "a"