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

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

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

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

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

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

f.z = l
f.v = b
b.s = l
l.z = f
l.v = b
assert l.z.z.v.txt == "b"