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

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

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

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

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

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

b.s = n
f.v = l
m.v = l
l.v = f
n.s = b
assert l.v.v.v.txt == "f"