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

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

b = A("b")
c = B("c")
k = B("k")
l = A("l")

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

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

b = A("b")
c = B("c")
k = B("k")
l = A("l")

b.o = l
b.v = c
c.r = k
c.z = l
k.r = c
k.z = l
l.o = b
l.v = k
assert k.z.o.o.o.txt == "b"