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

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

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

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

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

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

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