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

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

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

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

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

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

f.s = k
f.v = l
k.v = l
k.o = f
l.s = k
l.v = f
assert f.v.s.o.txt == "f"