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

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

b = A("b")
e = B("e")
f = A("f")

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

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

b = A("b")
e = B("e")
f = A("f")

b.r = e
b.o = e
e.z = b
e.v = b
f.r = e
f.o = e
assert b.r.z.r.txt == "e"