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

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

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

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

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

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

a.r = i
c.z = l
c.y = b
e.z = l
e.y = b
b.r = i
l.z = c
l.y = a
i.z = l
i.y = b
assert l.z.z.y.r.txt == "i"