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

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

i = A("i")
l = B("l")
j = B("j")
m = B("m")
c = A("c")
n = B("n")

i.s = j
l.w = n
j.w = l
m.w = n
c.s = m
n.w = m
assert l.w.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.txt = txt

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

i = A("i")
l = B("l")
j = B("j")
m = B("m")
c = A("c")
n = B("n")

i.s = j
l.w = n
j.w = l
m.w = n
c.s = m
n.w = m
assert l.w.w.w.txt == "n"